views:

151

answers:

1

Okay, I'm stumped. I'm fiddling with some project settings, trying to start linking against library Y instead of library X. When I search through the project file (.vcproj) and all the inherited property sheets (.vsprops), there are no references left to library X. I've closed and reopened Visual Studio to make sure it's not holding onto some old version of the project. However, as suggested by the title, I still get the link error

LINK : fatal error LNK1104: cannot open file 'X'

When I come across this sort of problem with header files (not knowing what file is including that header), I usually rename the problem header to cause a C1083: Cannot open include file error, which tells me what source file is requesting it. But here the LNK1104 is not nearly as useful. Does anyone have any ideas on how I can track this down? Thanks.

+3  A: 

Under project settings / linker / general there's a setting called "show progress", if you set it to "/VERBOSE" the linker will show you all kinds of stuff including the "/DEFAULTLIB" items it finds. This can be helpful, depending on whether the import is coming from a lib file, or not.

You should also search your solution source code for a "#pragma comment(lib,...", which causes a default library to be included at link-time.

If library X is something like msvcrt, then the dependency is likely coming from an external or third-party library that you're using, and the only practical way to avoid this is to add X to the "ignore specific library" option under project settings / linker / input.

Tim Sylvester
Thanks! That was indeed helpful.
Owen