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:
这是一个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)
--------------------------------------------------------------------------
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.
如果我使用/ NODEFAULTLIB,那么我会遇到大量错误。代码实际上并没有使用_socket_noblock,但我在'net上找不到任何内容。据推测它被我链接到的某些库使用,但我不知道它在哪个库中。
--- Alistair.
4 个解决方案
#1
3
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.
LNK4098可能不是问题。例如,如果链接某个库的发行版本,使用静态运行时链接并导致LIBCMT(注意“D”后缀的缺失)被添加到默认库中,则会发生这种情况。您的应用程序在Debug配置中构建,使用LIBCMTD,因此存在冲突。它实际上可能是安全的,只要您不与该库交换依赖运行时的任何内容。
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.
对于_socket_noblock,您可以使用一些搜索实用程序(例如grep或find)在.obj和.lib文件中搜索此字符串。这样,您将知道哪个库引用了该符号,这可能是发现库具有哪些依赖项的起点。
#2
1
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.
对不起,这是一个内部问题。 4年前一个特立独行的编码器和一个生锈的没有任何东西(我!)的组合现在。
The code does not use _socket_noblock
but it does use socket_noblock
and I just need to link to one of our own libraries.
代码不使用_socket_noblock,但它确实使用socket_noblock,我只需要链接到我们自己的库之一。
#3
1
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.
您可以使用“Dependency Walker” - 一个免费工具来查找应用程序的依赖关系,以确定应用程序如何链接到libcmtd。编辑:当然,您不能在新版本上使用它,但无法链接(请参阅注释),但您可以在旧版本或新版本链接的已知库上使用它。
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.
看起来您正在链接到不同版本的CRT - 可能是因为您使用旧的构建库以及新的编译器和CRT版本。
#4
0
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.
defaultlib“LIBCMTD”与使用其他库冲突是一个警告,表明您的程序使用与您的一个或多个库不同的运行时库版本。在程序和库中使用相同的运行时,以使警告消失。
(project settings) (c++ tab) category (Code Generation) (use runtime library)
(项目设置)(c ++选项卡)类别(代码生成)(使用运行时库)
#1
3
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.
LNK4098可能不是问题。例如,如果链接某个库的发行版本,使用静态运行时链接并导致LIBCMT(注意“D”后缀的缺失)被添加到默认库中,则会发生这种情况。您的应用程序在Debug配置中构建,使用LIBCMTD,因此存在冲突。它实际上可能是安全的,只要您不与该库交换依赖运行时的任何内容。
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.
对于_socket_noblock,您可以使用一些搜索实用程序(例如grep或find)在.obj和.lib文件中搜索此字符串。这样,您将知道哪个库引用了该符号,这可能是发现库具有哪些依赖项的起点。
#2
1
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.
对不起,这是一个内部问题。 4年前一个特立独行的编码器和一个生锈的没有任何东西(我!)的组合现在。
The code does not use _socket_noblock
but it does use socket_noblock
and I just need to link to one of our own libraries.
代码不使用_socket_noblock,但它确实使用socket_noblock,我只需要链接到我们自己的库之一。
#3
1
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.
您可以使用“Dependency Walker” - 一个免费工具来查找应用程序的依赖关系,以确定应用程序如何链接到libcmtd。编辑:当然,您不能在新版本上使用它,但无法链接(请参阅注释),但您可以在旧版本或新版本链接的已知库上使用它。
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.
看起来您正在链接到不同版本的CRT - 可能是因为您使用旧的构建库以及新的编译器和CRT版本。
#4
0
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.
defaultlib“LIBCMTD”与使用其他库冲突是一个警告,表明您的程序使用与您的一个或多个库不同的运行时库版本。在程序和库中使用相同的运行时,以使警告消失。
(project settings) (c++ tab) category (Code Generation) (use runtime library)
(项目设置)(c ++选项卡)类别(代码生成)(使用运行时库)