[CMake] Boost Link errors with Cmake

Andreas Pakulat apaku at gmx.de
Wed Jun 18 15:28:37 EDT 2008


On 18.06.08 14:03:39, Ravi Kavalipati wrote:
> When I run cmake the output says "-- Found the following Boost libraries:"
> but im getting undefined references errors for various boost 
> libraries, I think the boost libraries are not properly linked in my 
> program.
> 
> .../src/libhpx.a(parcelport_queue.cpp.o)(.text+0x3c0): In function `__tcf_15':
> : undefined reference to 
> `boost::archive::detail::basic_serializer_map::~basic_serializer_map()'
> ____________________________________________________________________
> #CMakeLists.txt
> # We require at least CMake V2.6
> cmake_minimum_required(VERSION 2.6)
> 
> # The name of our project is "hpx".  CMakeLists files in this project can
> # refer to the root source directory of the project as ${hpx_SOURCE_DIR} and
> # to the root binary directory of the project as ${hpx_BINARY_DIR}.
> project (hpx)
> 
> # We need to use Boost
> find_package(Boost 1.35.0 REQUIRED)
> INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
> INCLUDE_DIRECTORIES(${Boost_LIBRARY_DIRS})

This is not needed.

> LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
> __________________________________________________________________________
> Can anyone please help me analyze my mistake?

You don't link against any library at all, or you didn't show enough of
your cmake file. To link against libboost_archive... its best to use

target_link_libraries( <yourapp> ${Boost_ARCHIVE_LIBRARY})

Then you don't need the LINK_DIRECTORIES call and cmake will actually
know the full path to boost libs so it can order the link dirs properly.

Andreas

-- 
Life is to you a dashing and bold adventure.


More information about the CMake mailing list