Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker error LNK1104 with 'libboost_filesystem-vc100-mt-s-1_49.lib'

Tags:

c++

boost

During the process of linking my program to the boost::filesystem module in release mode I get the next error:

error LNK1104: cannot open file 'libboost_filesystem-vc100-mt-s-1_49.lib'

However, in the boost\stage\lib directory I only have the next libraries referred to filesystem module:

libboost_filesystem-vc100-mt-1_49.lib

libboost_filesystem-vc100-mt-gd-1_49.lib

My questions are:

Why does the VC++ is asking for 'libboost_filesystem-vc100-mt-s-1_49.lib?

Which compiler/linking properties should I change to get the compiler to ask for libboost_filesystem-vc100-mt-1_49.lib?

UPDATE: My VC2010++ solution has 2 projects that include the previous boost library: x is a library and y (the main program) which invokes to x.

  1. When I build x with Configuration type=Static library and RuntimeLibrary=Multi-threaded (/MT), it is ok.
  2. When I build y with Configuration type=Application (.exe) and RuntimeLibrary=Multi-threaded (/MT), it issues the error I indicated, if I change to Configuration type=Static library it builds ok, but my main program has .lib extension and not the expected .exe.
like image 789
vizcayno Avatar asked Mar 09 '12 03:03

vizcayno


3 Answers

You are using /MT or /MTd option in C/C++/Code Generation/Runtime Library which require static library, boost default build with shared library output. You can switch Runtime Library to /MD or /MDd. An other option is recompile boost with static library output and you'll get 'libboost_filesystem-vc100-mt-s-1_49.lib'..

like image 147
secmask Avatar answered Oct 17 '22 15:10

secmask


I had a similar problem with a recent project (inherited from a long legacy).

Here is a "poor man's" solution to this issue:

Rebuild the boost libraries with all variants, to be sure that you have the correct variant for your needs.

Run:

.\b2 --build-type=complete

Note that the boost build time will obviously be longer with this option.

This is not an elegant solution, but I didn't have time to mess about figuring out which exact option I needed for my project, so I just built them all.

like image 22
kalenwatermeyer Avatar answered Oct 17 '22 16:10

kalenwatermeyer


You can paste the following characters into you control console (win+r----cmd , then go to boost src directory , find the bjam.exe) ps:double click the bootstrap.bat can get bjam.exe

bjam --toolset=msvc-1.0 --stagedir=./lib_x64 --builddir=./ address-model=32 link=static variant=release runtime-link=static threading=multi stage debug releasde


libboost_filesystem-vc100-mt-s-1_49.lib


"link=static" correspond to -s-
"threading=multi" correspond to -mt-
"runtime-link=static" correspond to lib prefix
"variant=release" make sure libboost_filesystem-vc100-mt-s-1_49.lib don't contain -gd-
like image 6
huoyao Avatar answered Oct 17 '22 16:10

huoyao