"LIBCMT"与其他库+未解析的外部符号的使用发生冲突 [英] 'LIBCMT' conflicts with use of other libs + unresolved external symbols

查看:357
本文介绍了"LIBCMT"与其他库+未解析的外部符号的使用发生冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用OpenGL 3.2(+ libs)和FreeType2的程序.然后是另一个带有Boost和OpenSSL的程序. OpenGL方面是为了确保可以渲染文本,boost/openssl程序是用来建立安全的登录/游戏服务器.

I have a program using OpenGL 3.2(+libs) and FreeType2. Then an other program with Boost and OpenSSL. The OpenGL side was to make sure text could be rendered and the boost/openssl program is to do a secure login/game server.

这两个程序本身都能正常工作.

Both programs work fine by them selfs.

但是,将Boost和OpenSSL添加到游戏项目(GL + freetype)导致链接失败.

However adding Boost and OpenSSL to the game(GL + freetype) project caused it to fail to link.

我已经链接了以下库,包括其中的include文件夹.

I have linked the following libs as well as including there includes folder.

glimg.lib glutil.lib glfw.lib opengl32.lib freetype.lib glew32.lib user32.lib libeay32.lib ssleay32.lib

glimg.lib glutil.lib glfw.lib opengl32.lib freetype.lib glew32.lib user32.lib libeay32.lib ssleay32.lib

链接器错误是.

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__DeregisterEventSource@4
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA@36
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__RegisterEventSourceA@8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteDC@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetBitmapBits@12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__BitBlt@36
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetObjectA@12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__SelectObject@8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleBitmap@12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetDeviceCaps@8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleDC@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateDCA@16
1>.\BasicTexture.exe : fatal error LNK1120: 13 unresolved externals

运行时库设置为多线程DLL(/MD)

Runtime Library is set to Multi-threaded DLL (/MD)

我不知道该怎么办,我将非常感谢您的帮助.

I have no idea what to do I would really appreciate any help.

推荐答案

当编译器生成引用外部定义的对象或函数的代码而链接程序找不到这些错误消息时,将产生无法解决的外部错误消息.要生成调用函数调用的代码,编译器仅需要声明:

Unresolved external error messages are produced when the compiler generates code referencing externally defined objects or functions and the linker fails to find those. To generate code invoking a function call the compiler only needs a declaration:

extern "C" BOOL DeregisterEventSource ( HANDLE hEventLog );

这是足以产生call指令的信息(目标地址除外). extern关键字通知编译器该实现是在其他位置定义的.因此,它无法知道以后必须填写的目标地址.完成编译器后,链接器的工作就是将各个部分连接在一起.它使用从导入库中收集的信息来查找所需的偏移量.

This is enough information to produce a call instruction (except for the target address). The extern keyword informs the compiler that the implementation is defined elsewhere. Consequently it cannot know the target address which has to be filled in later. When the compiler is done it is the linker's job to connect the pieces together. It uses the information gathered from the import libraries to look up the required offsets.

在错误日志中可以轻松找到Windows API调用.它们具有__imp__前缀,有时带有AW后缀,后跟@<n>,其中< n> 表示参数所需的字节数.如果是Windows API调用,则可以在MSDN中查找该功能(例如 DeregisterEventSource ).底部是需求,您可以在其中找到导入库的名称.

Windows API calls are easily spotted in the error log. They have an __imp__ prefix and sometimes an A or W postfix followed by @<n> where <n> indicates the number of bytes required for the arguments. In the case of a Windows API call you can then look up the function in the MSDN (like DeregisterEventSource). Towards the bottom are the Requirements where you can find the import library name.

冲突警告表明并非所有模块都使用相同的运行时库.即使这只是一个警告,它也是一个严重的问题,应该解决.如果混合使用/MD/MT编译器开关,也会收到此警告,而且如果混合使用发行版和调试运行时库(例如/MD/MDd),也会收到此警告.要诊断此消息,可以使用 /VERBOSE:LIB 链接器开关来确定链接器是哪些库搜索.可以在此 MSDN链接中找到有关此警告的其他信息.

The conflict warning indicates that not all of the modules use the same runtime library. Even though this is just a warning it is a serious issue and should be resolved. You get this warning if you mix /MD and /MT compiler switches, but also, if you mix release and debug runtime libraries (like /MD and /MDd). To diagnose this message you can use the /VERBOSE:LIB linker switch to determine which libraries the linker is searching. Additional information on this warning can be found at this MSDN link.

这篇关于"LIBCMT"与其他库+未解析的外部符号的使用发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆