开发者

Why is VisualStudio looking for this lib file? LNK1104 error

We have a large project using VS2008 and boost 1_42. I'm trying to开发者_如何学Go upgrade to VS2010 and boost 1_44. I installed VS2010 and boost 1_44 and converted the project. Now I am trying to build, and everything compiles, but fails when linking:

LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-1_42.lib'

I have changed the include and lib directories to point to the new boost 1_44 files and I have renamed the old boost 1_42 directory.

Why is the linker still looking for a vc90-1_42 file, when it is only using 1_44 headers? Is there a way that I can determine WHY the linker wants this file? The linker obviously thinks it needs the file, but why?

I have cleaned the project and I am re-building to ensure any old build files are erased.


I've run into exactly this problem a couple of times too. It's usually been some old temporary files but like in your case cleaning didn't always do the trick straight away. Does your project include any static libs that might have been built with 1.42?

Something you can try which may or may not be helpful in tracking down your issue: Rename the old boost directory back to it's original name

  • Clean the solution
  • Under C/C++->Command Line->Additional Options add "/showIncludes"
  • Under Linker->Command Line->Additional Options add "/verbose:lib"
  • Rebuild all

Then when you build you'll be able to see at which point 1.42 headers are included, etc. in the output window. Somehow doing this helped me in tracking down where the problem was.


Along with changing the lib directory, you need to change the name of the boost library. That's in the Linker | Input section of the project settings.

Your added comment makes it clear that the dependency on the Boost 1.42 library was being created indirectly by another library that hadn't been rebuilt.

For this you basically have two choices: either add that library as a project to your main solution, and make sure it has enough dependency information that it'll be re-built when you upgrade Boost, or use the /Zl compiler switch when you build your library. This tells the compiler you're building a library so you do not want to embed library dependencies like this.


Boost uses

#pragma comment(lib)

command to inform the linker of libraries it needs to link with. It is not an error. If Boost says you need it, it's likely you do.


On How can I find out why the linker wants this file?

There are programs which will go through your app and dlls/libs and report the content of manifests and what the binaries report they depend on. You could then scan the report for the unexpected libraries being included. We used this mainly to find libs including the previous version of the VC runtime.

Have not used the one we had in about 5 years though, now if only I could remember the name of the app!

DependancyWalker (depends.exe) will allow you to see dependancies of dll/exe but not static libs.

You could open each binary as a 'file' in MSVS and look at the manifest content by hand, but I imaging this would be a bit painful. I've not tried this with a static lib.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜