VC 调试错误 专题

LNK1181: cannot open input file“1.obj”

  出错原因:在Pjoject--->Settings---->link---->input 写入需要库时在 末尾 输入一个 1

  解决方法:删除 多余的 1

VC编译错误:error LNK2001: 无法解析的外部符号 __iob

错误:

1>libxvidcore.lib(bitstream.obj) : error LNK2001: 无法解析的外部符号 __iob
1>libxvidcore.lib(mbprediction.obj) : error LNK2001: 无法解析的外部符号 __iob
1>libxvidcore.lib(mbcoding.obj) : error LNK2001: 无法解析的外部符号 __iob
1>libxvidcore.lib(image.obj) : error LNK2001: 无法解析的外部符号 __iob
1>libxvidcore.lib(decoder.obj) : error LNK2001: 无法解析的外部符号 __iob
1>libxvidcore.lib(encoder.obj) : error LNK2001: 无法解析的外部符号 __iob

原因:http://hi.baidu.com/yeyingxian/blog/item/0cfabcd38885cb32960a16e1.html

 

解决办法:

该错误主要是由于静态库在VC6编译而主程序在VC2005编译,大家用的CRT不同。解决办法,代码中增加

#ifdef __cplusplus
extern "C" 
#endif
FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};

3 使用G729a.lib 时出现编译错误

LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrt.lib(MSVCRT.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrt.lib(cinitexe.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in LIBCMT.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj)

现象是 本来我在VC6.0  Project Settings-->link--->input 中 lgnore libraries: LIBCMTD.LIB库

 

 

 

            现在 在程序中引入 基于G729a.lib的编解码类后 出现如上错误 如果 lgnore libraries: LIBCMTD.LIB libcmt.lib

 又会出现错误:

LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrt.lib(MSVCRT.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrt.lib(MSVCRT.dll)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrt.lib(MSVCRT.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrt.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrt.lib(cinitexe.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in LIBCMTD.lib(strncpy.obj)

原因在于:

我的代码其他地方都是用MSVCRT.LIB or MSVCRTD.LIB, 但是g729a.lib 用libcmt.lib不可能同时用两个运行时库,所以我要告诉linker 忽略libcmt.lib

所以在.cpp文件头加上

#pragma comment(linker, "/NODEFAULTLIB:libcmt.lib")

4

Run-Time Check Failure #2 - Stack around the variable 'dlg' was corrupted.

 出错位置:BOOL CIVASApp::InitInstance()

 原因是:

访问dlg内的数据的代码有访问越界错误

 5 

我在使用vc2005的类向导为控件生成变量时,发生了错误:在file://D:/Program Files/Microsoft Visual Studio 8/VC/VCWizards/CodeWiz/MFC/Variable/HTML/2052/default.htm的1587行提示对象不支持此属性或方法,错误页面如下

VC 调试错误 专题_第1张图片

 

 

 

 

 

VC 调试错误 专题_第2张图片

 

 

 

IE正式版引发VS2005和VS2008向导出错的解决方案.这个是VC++团队给出的.
第一时间测试成功.老外给出的解决方案,测试有效,大家试试.

请按照以下步骤做: 
- 启动注册表编辑器 regedit (在64位系统上也可以启动32位版本)
- 找到“HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet 
SettingsZones”, 建立一个名为1000的新键(如果没有的话).
- 在这个1000的键下,建立如下DWORD内容:
o Name = 1207 
o Type = REG_DWORD 
o Data = 0x000000

 

VC 调试错误 专题_第3张图片

6

 

而在VS2005写
MessageBox("Hello,World!");
出现错误提示:
error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [13]' to 'LPCTSTR'

解决方法是:
MessageBox(_T("Hello,World!"));或MessageBox(TEXT("Hello,World!"));

原因:
2005中默认的是unicode的,char是非unicode的。不同于以前在6.0中的写法MessageBox("Hello,World!")。
也可以在VS2005项目属性中改变设置 General->Character Set->Not Set


7

Error: forget to add '#include "stdafx.h"' to your source

在VC增加一个类调试时出现 “forget to add '#include "stdafx.h"' to your source” 时,是在编译时使用了 预编译头文件,所以需要设置不用 Precompiled Header.Project-->Property-->Configuraton Properties-->C/C++-->Precompiled Header-->Create/use Precompiled Header-->Not Using Precompiled Headers.
8

解决“LIBCMT.lib(dosmap.obj) : error LNK2005: __dosmaperr already defined in LIBCD.lib(dosmap.obj)”错误

当头文件中声明了一个函数,但是在相应的源文件中却没有对该函数进行定义,则会出现为“解决的外部符号”(unresolved external symbol )错误。另外,当一个函数调用了外部的一个库文件中的函数,但是在当前project的properties中并没有将所依赖的(dependent)库文件包含进来时,也会出现这种错误。

      综上,当一个solution在linking时找不到所涉及到的函数的定义时就会出现“unresolved external symbol ”错误。

      例如,下面是调用MIL的库文件mil.lib中的函数时,由于没有将mil.lib包含进来而导致的链接错误。

1>Linking...
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MappFree@4 referenced in function _main
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MsysFree@4 referenced in function _main
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MdispFree@4 referenced in function _main

      【解决方案】

      1. Project -> ** Properties... -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> mil.lib

另外,在此之前,还需添加MIL库的相应目录:Tools -> Options -> Projects and Solutions -> VC++ Directories -> Show Directories for -> 在Include files中添加C:\Program Files\Matrox Imaging\Mil\Include  以及  Tools -> Options -> Projects and Solutions -> VC++ Directories -> Show Directories for -> 在Library files中添加C:\Program Files\Matrox Imaging\Mil\LIB。添加目录的目的是为了使VC在调用相应库文件时不必总是使用绝对地址,VC可以通过文件名在所包含的目录中进行搜索。这样,前面的mil.lib就不必使用绝对地址了。

      【缺点】可移植性差,如果将原工程中的源文件和头文件中的内容copy下来重新建立该工程时(例如:在电子书或网络上找到的程序),仍需自己在工程中添加目录及所需的库文件。

      2. 在程序前加入#pragma comment(lib, "mil.lib")也可以达到相同的效果。

      【优点】避免了方案1所出现的问题。

9 error LNK2019:unresolved external symbol *** referenced in function ***的解决方案
当头文件中声明了一个函数,但是在相应的源文件中却没有对该函数进行定义,则会出现为“解决的外部符号”(unresolved external symbol )错误。另外,当一个函数调用了外部的一个库文件中的函数,但是在当前project的properties中并没有将所依赖的(dependent)库文件包含进来时,也会出现这种错误。

      综上,当一个solution在linking时找不到所涉及到的函数的定义时就会出现“unresolved external symbol ”错误。

      例如,下面是调用MIL的库文件mil.lib中的函数时,由于没有将mil.lib包含进来而导致的链接错误。

1>Linking...
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MappFree@4 referenced in function _main
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MsysFree@4 referenced in function _main
1>MDispSelect.obj : error LNK2019: unresolved external symbol _MdispFree@4 referenced in function _main

      【解决方案】

      1. Project -> ** Properties... -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> mil.lib

另外,在此之前,还需添加MIL库的相应目录:Tools -> Options -> Projects and Solutions -> VC++ Directories -> Show Directories for -> 在Include files中添加C:\Program Files\Matrox Imaging\Mil\Include  以及  Tools -> Options -> Projects and Solutions -> VC++ Directories -> Show Directories for -> 在Library files中添加C:\Program Files\Matrox Imaging\Mil\LIB。添加目录的目的是为了使VC在调用相应库文件时不必总是使用绝对地址,VC可以通过文件名在所包含的目录中进行搜索。这样,前面的mil.lib就不必使用绝对地址了。

      【缺点】可移植性差,如果将原工程中的源文件和头文件中的内容copy下来重新建立该工程时(例如:在电子书或网络上找到的程序),仍需自己在工程中添加目录及所需的库文件。

      2. 在程序前加入#pragma comment(lib, "mil.lib")也可以达到相同的效果。

      【优点】避免了方案1所出现的问题。


9 无法打开包括文件:“*.h”: No such file or directory

  导致这个问题的原因:

  1 .h所在的文件路径设置的不对

  2 没有将.h 文件引入工程中。

 

   在调试中 工程包括.exe 和lib 子工程,本来需要在lib 子工程中创建一个新类,但是实际错误的在.exe 子工程创建  由于.exe 子工程没有设置此.h 的路径导致 一直提示如上错误 但是自己一直还在.lib 子工程中找问题。

10 unexpected 'class'

当用VS编译程序时,提示

        error C2236: 意外的“class” 或者 error C2236: unexpected 'class'


注意检查当前类有无错误,如果确定当前类没有错误,那么检查当前类中include进来的类。


错误提示:

  类定义的最后,大括号后面是否忘了";"


你可能感兴趣的:(properties,function,include,tools,dependencies,linker)