如何解决这个 VC++ 6.0 链接器错误?
这是一个 Windows 控制台应用程序(实际上是一个服务),由前一个人在 4 年前构建并安装并运行。 我现在需要进行一些更改,但甚至无法构建当前版本! 这是构建输出:
--------------------Configuration: MyApp - Win32 Debug--------------------
Compiling resources...
Compiling...
Main.cpp
winsock.cpp
Linking...
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
Main.obj : error LNK2001: unresolved external symbol _socket_dontblock
Debug/MyApp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
MyApp.exe - 2 error(s), 1 warning(s)
--------------------------------------------------------------------------
如果我使用 /NODEFAULTLIB
那么我会收到大量错误。 该代码实际上并未使用 _socket_noblock
但我在网上找不到任何内容。 据推测,它被我链接到的某个库使用,但我不知道它在哪个库中。
--- Alistair。
This is a Windows Console application (actually a service) that a previous guy built 4 years ago and is installed and running. I now need to make some changes but can't even build the current version! Here is the build output:
--------------------Configuration: MyApp - Win32 Debug--------------------
Compiling resources...
Compiling...
Main.cpp
winsock.cpp
Linking...
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
Main.obj : error LNK2001: unresolved external symbol _socket_dontblock
Debug/MyApp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
MyApp.exe - 2 error(s), 1 warning(s)
--------------------------------------------------------------------------
If I use /NODEFAULTLIB
then I get loads of errors. The code does not actually use _socket_noblock
but I can't find anything on it on the 'net. Presumably it is used by some library I am linking to but I don't know what library it is in.
--- Alistair.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
LNK4098可能不是问题。 例如,如果您链接到某个使用静态运行时链接的库的发行版本,并导致 LIBCMT(注意没有“D”后缀)被添加到默认库中,则可能会发生这种情况。 您的应用程序是在调试配置中构建的,使用 LIBCMTD,因此会发生冲突。 它实际上可能是安全的,前提是您不与该库交换任何依赖于运行时的内容。
至于
_socket_noblock
,您可以使用一些搜索实用程序(例如grep或find)在.obj和.lib文件中搜索该字符串。 通过这种方式,您将知道哪个库引用了该符号,这可能是发现该库具有哪些依赖项的起点。LNK4098 may not be a problem. For example, it can occur if you link against a release version of some library which uses static runtime linkage and causes LIBCMT (note the absense of "D" suffix) to be added to default libraries. Your application, being built in Debug config, uses LIBCMTD, thus the conflict. It may be actually safe, provided that you are not exchanging anything runtime-dependant with that library.
As for
_socket_noblock
, you can use some search utility (such as grep or find) to search for this string in .obj and .lib files. This way you will know which library references the symbol, which may be a starting point for discovering what dependencies that library has.抱歉,这是一个内部问题。 一个 4 年前特立独行的程序员和现在生锈的一无所有(我!) 的组合。
该代码不使用
_socket_noblock
,但它确实使用socket_noblock
,我只需要链接到我们自己的库之一。Sorry, this turns out to be an internal problem. A combination of a maverick coder 4 years ago and a rusty no-nothing (me!) now.
The code does not use
_socket_noblock
but it does usesocket_noblock
and I just need to link to one of our own libraries.您可以使用 "Dependency Walker" - 一个免费工具来查找应用程序的依赖项,以了解如何您的应用程序正在链接到 libcmtd。
编辑:当然,您不能在无法链接的新版本上使用它(请参阅评论),但您可以在旧版本或新版本的已知库上使用它链接与.
然而,由于真正的问题与我建议的任何内容无关,也许这个问题应该结束。
看起来您正在链接到不同版本的 CRT - 可能是因为您将旧构建的库与新编译器和 CRT 版本一起使用。
You can use "Dependency Walker" - a free tool to find the dependencies of your application, to figure out how your application is linking to libcmtd.
Edit: You can't, of course, use that on the new version which fails to link (see comments), but you can use it on the old version, or on known libraries that the new version links with.
However, as the real problem was unrelated to anything I suggested, perhaps the question should be closed.
It looks like you are linking to different versions of the CRT - possibly because you are using old built libraries together with a new compiler and version of the CRT.
defaultlib "LIBCMTD" 与其他库的使用冲突 是一条警告,表明您的程序使用的运行时库版本与您的一个或多个库不同。
在程序和库中使用相同的运行时,以使警告消失。
(项目设置)
(C++ 选项卡)
类别(代码生成)
(使用运行时库)
defaultlib "LIBCMTD" conflicts with use of other libs is a warning that indicates that your program uses a different version of the run time library that one or more of your libraries.
Use the same runtime across the program and libraries, to make the warning go away.
(project settings)
(c++ tab)
category (Code Generation)
(use runtime library)