LNK2005:找到使用/MT构建的模块
我正在尝试构建 C++ 项目(mapserver)。这取决于其他一些项目。
当我运行 nmake
时,它显示了许多这样的错误:
...
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in MSVCRT.lib(MSVCR90.dll)
LIBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRT.lib(MSVCR90.dll)
LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRT.lib(MSVCR90.dll)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strnicmp already defined in LIBCMTD.lib(strnicmp.obj)
...
我知道这是由 /MD
和 /MT
选项与项目不同时引起的来投影。
我检查了所有项目的构建文件,只发现一个带有 /MT
的文件。我将其更改为 /MD
并重建它,但错误仍然存在。
如何找到导致此错误的库?
感谢大家!
PS项目列表:
curl-7.24.0
expat-2.0.1
freetype-2.4.8
gdal-1.9.0
gdwin32
jpeg-6b
lpng158
mapserver <-- main
postgresql-8.4.9
proj-4.7.0
regex-0.12
zlib
I'm trying to build C++ project (mapserver). It depends on some other projects.
When I run nmake
, it shows many errors like this:
...
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in MSVCRT.lib(MSVCR90.dll)
LIBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRT.lib(MSVCR90.dll)
LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRT.lib(MSVCR90.dll)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strnicmp already defined in LIBCMTD.lib(strnicmp.obj)
...
I know it is caused by /MD
and /MT
options when they differs from project to project.
I checked all project's build files and have found only one with /MT
. I changed it to /MD
and rebuilt it, but error remained.
How to find a library caused this error?
Thanks for all!
P.S. Project list:
curl-7.24.0
expat-2.0.1
freetype-2.4.8
gdal-1.9.0
gdwin32
jpeg-6b
lpng158
mapserver <-- main
postgresql-8.4.9
proj-4.7.0
regex-0.12
zlib
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看此知识库
http://msdn.microsoft。 com/en-us/library/6wtdswk0(v=vs.71).aspx
根据您尝试执行的构建使用忽略库行。如果您正在使用的库需要该库,您将得到该库的未找到符号,您可以修复它。
此外,您还可以使用 dumpbin 来找出库将尝试链接的内容。
Look at this KB
http://msdn.microsoft.com/en-us/library/6wtdswk0(v=vs.71).aspx
Use the ignore libraries line based on the build you are trying to do. If a library you are using needs that library, you will get a Symbol not Found for that library and you can fix it.
Also, you can use
dumpbin
to find out what a library will try to link to.结果发现解决方案非常简单。
我在主程序使用的每个库上运行 dumpbin 。其中之一是用
/MT
选项编译的。PS 有趣的是,构建文件不包含
/MT
或/MTd
选项。相反,它包含中
makefile
在我替换它的
,并且全部开始工作。
The solution turned out very simple.
I run
dumpbin
on each library that main program uses. One of them was compiled withthat means
/MT
option.P.S. It is interesting, that build file didn't contain
/MT
or/MTd
options. Instead, it includedwith
The makefile contained
I replaced it with
and all begun to work.