windows 如何删除警告 LNK4099:未找到 PDB 'lib.pdb'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25843883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove warning LNK4099: PDB 'lib.pdb' was not found
提问by Donal Lafferty
LNK4099 warnings can occur when building on Windows during the link phase of a static compilation.
在静态编译的链接阶段在 Windows 上构建时,可能会出现 LNK4099 警告。
E.g. when building using nmake and VC10 I get a stream of LNK4099 warnings like:
例如,在使用 nmake 和 VC10 构建时,我收到了 LNK4099 警告流,例如:
libcurl_a_debug.lib(rc2_cbc.obj) : warning LNK4099: PDB 'lib.pdb' was not found with 'libcurl_a_debug.lib(rc2_cbc.obj)' or at 'C:\dev\scaler\center\dlux\lib.pdb'; linking object as if no debug info
StackOverflow gives a good overview of the problem, but not the detail required to understand it.
StackOverflow很好地概述了问题,但没有提供理解它所需的细节。
Rather than ignore the warningor disable the warning, I would like to fix the makefiles in my build to remove the problem.
而不是忽略警告或禁用警告,我想解决的makefile在我的构建中删除的问题。
How does the problem arise? How do I remove the cause of the warnings?
问题是如何产生的?如何消除警告的原因?
回答by Donal Lafferty
Understand that the underlying problem is a missing debug symbols file (.pdb) for the library mentioned in the warning. Library files contain a static reference to the .pdb on an object file basis. When a library is used by another library and static compilation is used, Visual Studio collects all the symbols into a single .pdb and the .pdb references in the object files are updated. However, if it cannot find the symbols, it will leave the old path in place.
了解潜在问题是警告中提到的库缺少调试符号文件 (.pdb)。库文件包含基于对象文件的对 .pdb 的静态引用。当一个库被另一个库使用并使用静态编译时,Visual Studio 将所有符号收集到一个 .pdb 中,并且更新对象文件中的 .pdb 引用。但是,如果它找不到符号,它将保留旧路径。
Fix the warning by recompiling the library mentioned in the warnings, and make sure the compiler has access to the .pdb of every referenced library. This involves determining which .pdb file cannot be found, and then making changes to ensure the .pdb can be found.
通过重新编译警告中提到的库来修复警告,并确保编译器可以访问每个引用库的 .pdb。这涉及确定无法找到哪个 .pdb 文件,然后进行更改以确保可以找到 .pdb。
Which object file (and thus library) are we missing the symbols (.pdb) for?
我们缺少哪个目标文件(以及库)的符号(.pdb)?
@gothprovided a blog link explaining where the .pdb reference comes from, but here is my summary:
@goth提供了一个博客链接,解释了 .pdb 引用的来源,但这里是我的总结:
A library contains a number of object files. Each object file includes a path to the debug symbols. We can use tools extract this information. Based on the object file and path, we can figure out which debug symbols file (.pdb) could not be found.
一个库包含许多目标文件。每个目标文件都包含调试符号的路径。我们可以使用工具提取这些信息。根据目标文件和路径,我们可以找出找不到哪个调试符号文件(.pdb)。
Open the Visual Studio Command Prompt. This creates a command shell with environment variables required to access Visual Studio tools. (Should be under "Visual Studio Tools" buried in the Start Menu, but this varies)
Obtain the internal path of the object file in the library using the
lib
tool's/list
option. E.g.
打开 Visual Studio 命令提示符。这将创建一个带有访问 Visual Studio 工具所需的环境变量的命令外壳。(应该在埋在开始菜单中的“Visual Studio 工具”下,但这会有所不同)
使用
lib
工具的/list
选项获取库中目标文件的内部路径。例如
C:\dev\libcurl\win\lib>lib /list libcurl_a_debug.lib > list_of_object_files_in_library.txt
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>more list_of_object_files_in_library.txt
Microsoft (R) Library Manager Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/file.obj
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/timeval.obj
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/rc2_cbc.obj
...
- Using the path, extract the object file using the
lib
tool's/extract
option.
- 使用路径,使用
lib
工具的/extract
选项提取目标文件。
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>lib /extract:..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/timeval.obj libcurl_a_debug.lib
Microsoft (R) Library Manager Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
- The object file contains a debug section called
.debug$T
that we can extract using thedumpbin
tool. E.g.
- 目标文件包含一个调试部分
.debug$T
,我们可以使用该dumpbin
工具提取该部分。例如
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>dumpbin /section:.debug$T /rawdata rc2_cbc.obj > dump_of_object_file_debug_info.txt
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>more dump_of_object_file_debug_info.txt
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file ./rc2_cbc.obj
File Type: COFF OBJECT
SECTION HEADER #9
.debug$T name
0 physical address
0 virtual address
5C size of raw data
1D53 file pointer to raw data (00001D53 to 00001DAE)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42100040 flags
Initialized Data
Discardable
1 byte align
Read Only
RAW DATA #9
00000000: 04 00 00 00 56 00 15 15 03 7A 47 A3 3D 4A 8C 4B ....V....zGú=J.K
00000010: A2 A5 26 D3 D6 57 15 46 3A 00 00 00 73 3A 5C 73 ó?&?íW.F:...s:\s
00000020: 63 61 6C 65 78 2E 6E 65 77 5C 63 65 6E 74 72 6F caler.new\center
00000030: 5C 6F 70 65 6E 73 73 6C 5C 62 75 69 6C 64 5C 6F \openssl\build\o
00000040: 70 65 6E 73 73 6C 2D 31 2E 30 2E 30 62 5C 74 6D penssl-1.0.0b\tm
00000050: 70 33 32 5C 6C 69 62 2E 70 64 62 00 p32\lib.pdb.
Summary
5C .debug$T
Above, you see that the object file says its debug symbols s:\scaler.new\center\openssl\build\openssl-1.0.0b\tmp32\lib.pdb
. Therefore, the problem lies with the .pdb generated when we built the openssl library used by libcurl.
在上面,您会看到目标文件显示了它的调试符号s:\scaler.new\center\openssl\build\openssl-1.0.0b\tmp32\lib.pdb
。因此,问题在于我们构建libcurl使用的openssl库时生成的.pdb。
How do I add the debug symbols to the library generating the warning?
如何将调试符号添加到生成警告的库中?
The /Fd option governs the name and location of the .pdb symbols file. E.g. when compiling libcurl, I used the following flags:
该/依存选项支配的.pdb符号文件的名称和位置。例如,在编译 libcurl 时,我使用了以下标志:
...
!IF DEFINED(VC10)
NT_MAK_FLAGS = APP_CFLAG="/GX /GZ /MTd /Fdtmp32.dbg/app" LIB_CFLAG="/Zl /Z7 /Fdtmp32.dbg/lib"
!ENDIF
...
The symbol file name of lib.pdb
and its path relative to the build is given by /Fdtmp32.dbg/lib
.
的符号文件名lib.pdb
及其相对于构建的路径由/Fdtmp32.dbg/lib
.
The problem is that the NT_MAK_FLAGS
is reused for a number of libraries that are generated when openssl is compiled. As a result, lib.pdb
is clobbered (overwritten) for all but the last library. To resolve the problem, each library should be given .pdb with a unique name. To simplify matters further, ensure that the compilation location is in the same tree as the libcurl
build.
问题在于,NT_MAK_FLAGS
openssl 编译时生成的许多库都重用了 。结果,lib.pdb
除了最后一个库之外的所有库都被破坏(覆盖)。要解决此问题,应为每个库提供具有唯一名称的 .pdb。为了进一步简化问题,请确保编译位置与libcurl
构建位于同一棵树中。
回答by Owen Ransen
This happened to me with a library .lib and maybe the attached image will help others. In my case I had to make sure that the .lib and the .pdb file were in the same directory, so note how $(OutDir) appears in the settings.
这发生在我的图书馆 .lib 上,也许附加的图像会帮助其他人。就我而言,我必须确保 .lib 和 .pdb 文件位于同一目录中,因此请注意 $(OutDir) 在设置中的显示方式。
I think they got misaligned when I imported an old 32 bit VS2010 project into VS2013 and set it up for 64 bits.
我认为当我将旧的 32 位 VS2010 项目导入 VS2013 并将其设置为 64 位时,它们没有对齐。
So I end up with this (good) situation:
所以我最终遇到了这种(好的)情况: