属性-配置属性-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