Visual Stdio C++ 编译常见问题

1. new 数组出现崩溃

new 数组时数组下标出现负值,但未做出错处理;

new数组,数组字节数大于4MB的时候有可能出现crash!

解决办法: 加入 try  catch 后,这样的错误几乎没有了,但是这样不是解决办法,只是给程序埋了个地雷。

try{
cur_img.data[0] = new uint8_t[1280*720];
cur_img.data[1] = new uint8_t[1280*360];
cur_img.data[2] = new uint8_t[1280*360];
}catch(...){}


2. LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

方案一:(这个方法比较好,在用qt运行时出现问题也能解决)

复制 C:\Windows\winsxs\x86_netfx-cvtres_for_vc_and_vb_b03f5f7f11d50a3a_6.1.7601.17514_none_ba1c770af0b2031b 目录下的 cvtres.exe 到C:\Program Files\Microsoft Visual Studio 10.0\VC\bin 目录下,直接覆盖替换。


3. Link 2001 无法解析的外部符号 的一些可能的原因

未包含系统库文件





4. ffmpeg遇到inttypes.h和UINT64_C

错误一:无法打开包括文件:“inttypes.h”: No such file or directory
解决方法:删除之,并在其之前添加如下代码:

#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#      define CONFIG_WIN32
#endif
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES)
#      define EMULATE_INTTYPES
#endif
#ifndef EMULATE_INTTYPES
#     include <inttypes.h>
#else
      typedef signed char    int8_t;
      typedef signed short int16_t;
      typedef signed int     int32_t;
      typedef unsigned char    uint8_t;
      typedef unsigned short uint16_t;
      typedef unsigned int     uint32_t;
#     ifdef CONFIG_WIN32
          typedef signed __int64     int64_t;
          typedef unsigned __int64 uint64_t;
#     else /* other OS */
          typedef signed long long     int64_t;
          typedef unsigned long long uint64_t;
#     endif /* other OS */
#endif /* EMULATE_INTTYPES */

错误二: error C3861: “UINT64_C”: 找不到标识符
解决方法:在common.h中添加如下代码:

#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif


5 _‘avcodec_decode_audio3': 被声明为已否决

下面是几种解决方法
1)Project Properties > Configuration Properties > C/C++ > General > SDL checks关掉
2) #pragma warning(disable: 4996)          
3) /wd 4996

4) .其实最好使用ffmpeg最新版本的函数:avcodec_decode_audio4


6.XTToolKit 出现如下错误 

r C1189: #error :  This build configuration is not supported by the evaluation library, choose either 'Debug' or 'Unicode Debug'.

项目---设置----在动态库(DLL)中使用MFC


7. VS  Debug 模式下断点有问题,运行时无法加断点 

工具-》选项-〉调试-〉编辑并继续-〉启用本机编辑并继续勾选上即可



8. fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h

1) 在解决方案资源管理器中,右击相应的.cpp文件,点击“属性”
2) 在左侧配置属性中,点开“C/C++”,单击“预编译头”

3) 更改右侧第一行的“创建/使用预编译头”,把选项从“使用预编译头(/Yu)”改成“不使用预编译头

9.错误:_cdecl 在obj中 定义

函数名前面加上static



10 出现fatal error rc1107 错误的处理办法

工具 -> options -> project and solutions -> vc++ directorie
把右边include files里面的路径的最后面的‘\’去掉

例如
原来是:     $(VCInstallDir)include\
改成:        $(VCInstallDir)include

——上面只是一个举例,我自己是因为OpenCV的include后面不小心带了个‘\’。。囧










posted @ 2015-12-11 10:34  洛笔达  阅读(733)  评论(0编辑  收藏  举报