[CMake] error of mixed dynamic/static link to Boost in windows VS2008

Mateusz Loskot mateusz at loskot.net
Fri Jan 6 05:30:19 EST 2012


On 6 January 2012 05:30, Forest Yang <yzine0511 at gmail.com> wrote:
>  I am writing a library using boost_regex. For the unit test part, I
> am using boost_unit_test_framework and needs to be dynamical linked.
> Everything worked great on Linux but not the Windows VS 2008.
>
>  I used the BoostPro binary installer, got boost components like:
> boost_regex-vc90-mt-gd-1_47.dll and .lib,  also the
> libboost_regex-vc90-mt-gd-1_47.lib file. After the FIND_PACKAGE(Boost
> Components ...) I got the boost_*-vc90-mt-gd-1_47.lib version, (no
> prefix lib), however, when I compile the unit test executable, it has
> an error fatal error LNK1104: cannot open file
> 'libboost_regex-vc90-mt-gd-1_47.lib' If I add its directory C:\Program
> Files\boost\boost_1_47\lib to the linker's "Additional Library
> Directory" in VS2008 everything went OK.
>
>  My question is
>
> 1. Where this "libboost*" comes from ? all my CMake script are giving
> boost_* instead of libboost_* libraries.
> 2. When to set this linker directory so I do not need to add this
> manually in VS2008.

The libboost_* libraries are dragged in by auto-linking on Windows.
Auto-linking is ON by default on Windows.
You have to explicitly disable it.

Go to CMake installation directory, locate FindBoost.cmake file,
open this file and read the comments where you have it explained very well.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list