To make a short story even shorter, I compiled the gperf2.0 project, and added the output to another project, in a “lib\Release” and “lib\Debug” folder.
Then, I added the libtcmalloc_minimal.lib file to the linker input for the release configuration, and libtcmalloc_minimal-debug.lib for the debug configuration, with the Additional Library Folders set to: $(ProjectDir)lib\Release for Release, and $(ProjectDir)lib\Debug for Debug.
I also added a post build event: copy “$(ProjectDir)lib\Release*.” “$(TargetDir)” for Release and copy “$(ProjectDir)lib\Debug.*” “$(TargetDir)” for Debug.
The problem?
Error 3 fatal error LNK1181: cannot open input file ‘..\lib\Debug\libtcmalloc_minimal-debug.lib’ Framework Framework
And it gives me that when I build the project in Release config. Why would it use the debug lib? I triple checked the command line output, and it uses the correct folder. So what gives? (/LIBPATH:”g:\licenta\Framework-transfer_RO-03may-94b4df\Framework\Framework\lib\Release”)
EDIT
I should also add that the compilation was successful, on another PC, where I added the lib path manually, without the use of $ keywords. However, on this PC, even with the lib file compiled on it, it gives me that linker error. I hate the linker.
EDIT 2
I should also mention that the the lib file is an import library for a dll. The dll was compiled on both PC’s.
EDIT 3
Even with the lib path added manually, it doesn’t work. I’ve been tryin to figure out this problem for an hour, and it’s annoying. I really hate the linker.
EDIT 4
I have removed every reference to that lib file, including the header, dll, anything. It still gives me this:
Error 3 fatal error LNK1181: cannot open input file ‘..\lib\Debug\libtcmalloc_minimal-debug.lib’ Framework Framework
What.The.
Don’t use the Linker project properties to try to solve this problem. Instead, add the library directly to the project by right-clicking on the project name in the Solution Explorer window, choosing “Add Existing Item”, and using the file browser to select the
.libfile you want.It’s a little more complicated since you want to have both the Debug and Release versions of the library. To solve this, add both
libtcmalloc_minimal.libandlibtcmalloc_minimal-debug.libto the project using the method I described. Then:libtcmalloc_minimal.lib(in the Solution Explorer window), choose Properties, set the Configuration to “Debug” and set “Excluded From Build” to YES. Click OK.libtcmalloc_minimal-debug.lib, only this time you have the “Release” configuration as the one with “Excluded From Build” = YES.(So the Release
libtcmallocis excluded in the Debug version, and the Debuglibtcmallocis excluded in the Release version. Otherwise it would try to link both libraries at the same time.)Visual Studio knows that if a
.libfile is listed in the project files, it should be passed to the linker with the correct relative path. It also knows not to bother with any files in the project that have “Excluded From Build” set for the current configuration (Debug or Release).