Boost logo

Boost Interest :

Subject: [Boost-cmake] Possible linker error
From: motes motes (mort.motes_at_[hidden])
Date: 2009-10-05 15:55:24


I am trying to build an application using boost with CMake on Ubuntu
9.04. This is the content of my CMakeList.txt file:

cmake_minimum_required(VERSION 2.6)

IF(Boost_unit_test_framework_LIBRARY)

  GET_FILENAME_COMPONENT(LIB_EXTENSION ${Boost_unit_test_framework_LIBRARY} EXT)

  IF(LIB_EXTENSION STREQUAL ".so")

    ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)

  ENDIF(LIB_EXTENSION STREQUAL ".so")

ENDIF(Boost_unit_test_framework_LIBRARY)

SUBDIRS(mytests)

FIND_PATH(BOOST_LIB REQUIRED)
INCLUDE_DIRECTORIES(${BOOST_LIB})

ADD_EXECUTABLE(unit_test_text src/unit_test_text.cpp)

TARGET_LINK_LIBRARIES(unit_test_text ${Boost_unit_test_framework_LIBRARY} )

ADD_TEST( unit_test_text unit_test_text )

After running CMake with the above file I run make from the build dir.
But I get this error:

Scanning dependencies of target unit_test_text_file_reader
[100%] Building CXX object
mytests/text/CMakeFiles/unit_test_text.dir/src/unit_test_text.cpp.o
Linking CXX executable unit_test_text
/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crt1.o: In
function `_start':
/build/buildd/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:109:
undefined reference to `main'
CMakeFiles/unit_test_text_file_reader.dir/src/unit_test_text.cpp.o: In
function `global constructors keyed to _Z20init_unit_test_suiteiPPc':

This smells of missing linker commands in my CMakeLists.txt file, but
what should I link against?


Boost-cmake list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk