cmake can't find boost libraries because it lo

2019-07-15 10:59发布

问题:

I've built the boost (1.56) libraries on a windows (8.1) machine according to the documentation, both as shared and static libraries.
All of them appear in the BOOST_ROOT/stage/lib directory in the following file name format:

boost_thread-vc120-mt-1_56.dll
boost_thread-vc120-mt-1_56.lib
boost_thread-vc120-mt-gd-1_56.dll
boost_thread-vc120-mt-gd-1_56.lib

(this is just the thread lib, the same format is used for all the other libs as well)

When I run cmake it complains about not being able to find the boost libraries.
Running it with -DBoost_DEBUG=ON shows that it looks for different file names:

libboost_thread-vc120-mt-s-1_56;
libboost_thread-vc120-mt-s;
libboost_thread-mt-s-1_56;
libboost_thread-mt-s;
libboost_thread

I noticed the following differences:

  • The prefix for the actual files is boost and not libboost as cmake is searching for
  • The static version of the actual files just has a different file extension (.lib instead of .dll) but cmake is looking for -mt-s

Any idea how I can make cmake find the actual files without renaming the files I have to match cmake's search formats?

Thanks

回答1:

Note: boost_thread-vc120-mt-1_56.lib is an import library allowing dynamic linking with boost_thread-vc120-mt-1_56.dll, while libboost_thread-vc120-mt-s-1_56 is a static library (s letter means it's also statically linked with CRT).

The application you try to build expects static Boost libraries having static CRT, so you should provide them. To build such libraries, invoke b2 with the appropriate parameters:

b2 variant=release link=static runtime-link=static stage