to myself 的分类学习日志

做自己想做的事
posts - 232, comments - 6, trackbacks - 0, articles - 0

VC编译错误

Posted on 2010-09-11 13:30 kongkongzi 阅读(431) 评论(0)  编辑 收藏 引用 所属分类: windows programming

收集各种崩溃错误及其解决办法

一、

出错触发:
 增加了一个第三方库(G3D)。
错误输出:
 unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(void)"
 unresolved external symbol __imp__strncpy
 unresolved external symbol __imp__memmove_s

解决办法:
 Try ignoring msvcrt.lib and linking in libcmt.lib?
 I finally got my /MD to run against the problem that I had.
 I removed 'msvcrt.lib' from my Ignore Specific Library list (under the release options).
 Have you set your debug build to use multi threaded debug dll?
 ignoring: libcmtd.lib  msvcprtd.lib

 LNK2005: <...> already defined in LIBCD.lib(osfinfo.obj)
 Your libraries are mismatched: singlethreaded/multithreaded/multithreaded dll.
 Check your compiler options to make sure you are using 'Multithreaded Debug DLL' (or /MDd) for debug builds
 and 'Multithreaded DLL' (or /MD) for release builds. (MSVC: in project settings under C++ > Code Generation).

G3D里有下面的定义,注释掉就可以了。
#ifdef _DEBUG
    #pragma comment (linker, 
"/NODEFAULTLIB:libc.lib")
    #pragma comment (linker, 
"/NODEFAULTLIB:libcmt.lib")
    #pragma comment (linker, 
"/NODEFAULTLIB:msvcrt.lib")
    #pragma comment (linker, 
"/NODEFAULTLIB:libcd.lib")
    #pragma comment (linker, 
"/NODEFAULTLIB:msvcrtd.lib")
#else
    #pragma comment(linker, 
"/NODEFAULTLIB:LIBC.LIB")
    #pragma comment(linker, 
"/NODEFAULTLIB:msvcrt.lib")
    #pragma comment(linker, 
"/NODEFAULTLIB:libcd.lib")
    #pragma comment(linker, 
"/NODEFAULTLIB:libcmtd.lib")
    #pragma comment(linker, 
"/NODEFAULTLIB:msvcrtd.lib")
#endif