LNK4099 warnings can occur when building on Windows during the link phase of a static compilation.
E.g. when building using nmake and VC10 I get a stream of LNK4099 warnings like:
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.
Rather than ignore the warning or disable the warning, I would like to fix the makefiles in my build to remove the problem.
How does the problem arise? How do I remove the cause of the warnings?
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.
I think they got misaligned when I imported an old 32 bit VS2010 project into VS2013 and set it up for 64 bits.
So I end up with this (good) situation:
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.
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.
Which object file (and thus library) are we missing the symbols (.pdb) for?
@goth provided a blog link explaining where the .pdb reference comes from, but here is my summary:
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.
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.lib
tool's/extract
option..debug$T
that we can extract using thedumpbin
tool. E.g.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.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:
The symbol file name of
lib.pdb
and its path relative to the build is given by/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 thelibcurl
build.