屬性-配置屬性-c/c++-代碼生成-運行庫:多線程(/MT)c++
而後會發生一些諸如:多線程
LNK2001 沒法解析的外部符號 __except_handler4_common msvcrt.lib函數
LNK2001 沒法解析的外部符號 __imp__strstrthis
等問題。線程
__except_handler4_common:code
The error message is actually saying the the function __except_handler4
, defined in MSVCRT.LIB, references the undefined symbol __except_handler4_common
. So it's not your code that's making the this reference, it's Visual Studio 2015's code.orm
The symbol __except_handler4_common
is defined in vcruntime.lib. This file should be automatically be linked in. I'm not sure why it wasn't. Did you select the static runtime library in the project options ("Multi-threaded (/MT)"), but then manually add MSVCRT.LIB (part of the dynamic C runtime libary)string
就把相應的庫加入到:鏈接器-輸入-附加依賴項, 就能夠了,好比:libvcruntime.lib(注意:使用vcruntime.lib依然會依賴vcruntime140.dll,以lib開頭的libxxx.lib纔是真正的靜態連接庫)it
__imp__strstr :io
若是懶得找庫,就直接聲明一個,把vc自帶函數封裝進去就能夠了,好比:
#ifdef __GNUC__ #elif defined(_MSC_VER) //solve the problem of mingw64 cross compiling symble lost. _CRT_STDIO_INLINE int __CRTDECL __ms_vsnprintf( _Out_writes_opt_(_BufferCount) _Always_(_Post_z_) char* const _Buffer, _In_ size_t const _BufferCount, _In_z_ _Printf_format_string_ char const* const _Format, va_list _ArgList) { vsnprintf(_Buffer, _BufferCount, _Format, _ArgList); return 0; } _VCRTIMP char _CONST_RETURN* __cdecl __imp__strstr( _In_z_ char const* _Str, _In_z_ char const* _SubStr ) { strstr(_Str, _SubStr); return 0; } #endif