前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vc编译去掉vcruntime140.dll依赖

vc编译去掉vcruntime140.dll依赖

作者头像
战神伽罗
发布2019-07-24 16:25:46
2.4K0
发布2019-07-24 16:25:46
举报
文章被收录于专栏:Eureka的技术时光轴

属性-配置属性-c/c++-代码生成-运行库:多线程(/MT)

然后会发生一些诸如:

LNK2001 无法解析的外部符号 __except_handler4_common msvcrt.lib

LNK2001 无法解析的外部符号 __imp__strstr

等问题。

__except_handler4_common:

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.

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)

就把相应的库加入到:连接器-输入-附加依赖项, 就可以了,比如:libvcruntime.lib(注意:使用vcruntime.lib依然会依赖vcruntime140.dll,以lib开头的libxxx.lib才是真正的静态链接库)

__imp__strstr :

如果懒得找库,就直接声明一个,把vc自带函数封装进去就可以了,比如:

代码语言:javascript
复制
#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
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档