程序出错如下:
Linking...
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(strcat.obj) : error LNK2005: _strcpy already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in LIBCMTD.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
CDXFilter.obj : error LNK2001: unresolved external symbol "public: static struct IPin * __cdecl UFilterUtils::GetPin(struct IBaseFilter *,int,char const *)" (?GetPin@UFilterUtils@@SAPAUIPin@@PAUIBaseFilter@@HPBD@Z)
CDXFilter.obj : error LNK2001: unresolved external symbol "public: static int __cdecl UFilterUtils::GetPinCount(struct IBaseFilter *,int &,int &)" (?GetPinCount@UFilterUtils@@SAHPAUIBaseFilter@@AAH1@Z)
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/ManageSystem.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Creating browse info file...
ManageSystem.exe - 13 error(s), 2 warning(s)
后来查了解决上面LNK2005的错误是忽略msvcrtd.lib库
加一句#pragma comment(linker, "/NODEFAULTLIB:msvcrtd.lib")
但是又出现下面的错:
Linking...
LINK : warning LNK4049: locally defined symbol "_strstr" imported
LINK : warning LNK4049: locally defined symbol "__setmbcp" imported
CDXFilter.obj : error LNK2001: unresolved external symbol __imp__wcscpy
CDXFilter.obj : error LNK2001: unresolved external symbol "public: static struct IPin * __cdecl UFilterUtils::GetPin(struct IBaseFilter *,int,char const *)" (?GetPin@UFilterUtils@@SAPAUIPin@@PAUIBaseFilter@@HPBD@Z)
CDXFilter.obj : error LNK2001: unresolved external symbol "public: static int __cdecl UFilterUtils::GetPinCount(struct IBaseFilter *,int &,int &)" (?GetPinCount@UFilterUtils@@SAHPAUIBaseFilter@@AAH1@Z)
Debug/ManageSystem.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Creating browse info file...
ManageSystem.exe - 4 error(s), 2 warning(s)
忽略msvcrtd.lib后出现新错
error LNK2001: unresolved external symbol __imp__wcscpy
希望高手指导,谢谢!!
------解决方案--------------------------------------------------------
额。。。恰恰相反,因为LIBCMTD.lib与MSVCRTD.lib冲突了,所以可以这样解决试试:
忽略所有默认库,然后DEBUG连MSVCRTD.lib,Release连MSVCRT.lib,DSHOW的话再把BaseClass编译的库也连上,其他库看工程需要,这样应该就可以了。
------解决方案--------------------------------------------------------
这样忽略库可能能成功,也可能有的正常函数会link找不到的。可以在工程link属性页command line -> addtional options编辑框输入/FORCE:MULTIPLE可以了。
但这不是问题的根本,出现这种问题是因为你的工程和所引用的静态库(strmbasd.lib, strmbase.lib)运行时库链接方式不一样所致,可能一个静态链接(/MT,/MTd),一个是动态链接(/MD,/MDd),VC工程默认都是动态链接的,最好是将它们调成一样,建议都调成静态链接,因为这样程序运行可以不依赖VC的运行时库(MSVCRT.dll等)了,编译出来的文件也只大一点点。否则系统要安装运行时库,而且运行时库子版本不一样还可能导致程序运行出错。这个可以用depends.exe查看程序或动态库所依赖的动态库。
------解决方案--------------------------------------------------------
用的什么编译器?vs2003,vs2005