[CMake] Error linking with Boost

Russell Wallace russell.wallace at gmail.com
Sun Aug 26 00:47:12 EDT 2012


I'm trying to compile a program that uses Boost, on Windows with Microsofts C++.

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
set(Boost_USE_STATIC_LIBS ON)
find_package(boost COMPONENTS program_options)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
file(GLOB sources . src/*.cc)
add_executable(ayane ${sources})
target_link_libraries(ayane ${Boost_LIBRARIES})

cmake appears to run successfully, compiling appears to run
successfully until the link stage, then I get this:

Linking CXX executable ayane.exe
LINK : fatal error LNK1104: cannot open file
'libboost_program_options-vc100-mt-gd-1_51.lib'
LINK Pass 1 failed. with 2
NMAKE : fatal error U1077: 'c:\CMake\bin\cmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

The library file in question does exist, and cmake appears to
understand what directory it's in. On the other hand, the stuff it
generates doesn't seem to contain any instructions referring to that
library file. What am I missing?

C:\ayane\build>ack -a -i boost
CMakeCache.txt
17://The directory containing a CMake configuration file for Boost.
18:Boost_DIR:PATH=Boost_DIR-NOTFOUND
21:Boost_INCLUDE_DIR:PATH=C:/boost
23://Boost library directory
24:Boost_LIBRARY_DIRS:FILEPATH=C:/boost/stage/lib
26://Boost diagnostic define
27:Boost_LIB_DIAGNOSTIC_DEFINITIONS:STRING=-DBOOST_LIB_DIAGNOSTIC
168://ADVANCED property for variable: Boost_INCLUDE_DIR
169:Boost_INCLUDE_DIR-ADVANCED:INTERNAL=1
170://ADVANCED property for variable: Boost_LIBRARY_DIRS
171:Boost_LIBRARY_DIRS-ADVANCED:INTERNAL=1
172://The library version string for boost libraries
173:Boost_LIB_VERSION:INTERNAL=1_51
174://The version number for boost libraries
175:Boost_VERSION:INTERNAL=105100

CMakeFiles/ayane.dir/flags.make
5:CXX_FLAGS =  /DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR /D_DEBUG /MDd
/Zi /Ob0 /Od /RTC1 -IC:\boost

CMakeFiles/CMakeDirectoryInformation.cmake
10:  "C:/boost"

CMakeFiles/Makefile.cmake
36:  "c:/CMake/share/cmake-2.8/Modules/FindBoost.cmake"


More information about the CMake mailing list