|
Boost Interest : |
Subject: Re: [Boost-cmake] Possible linker error
From: Mike Jackson (mike.jackson_at_[hidden])
Date: 2009-10-07 13:36:33
I'll answer the same way I answered in the CMake mailing list that you
posted the SAME question to.
Use find_package(..) then use the variables that FindBoost.cmake
provides you. Consult the original reply from me in the CMake Mailing
list for the rest of the answer.
If you choose to ignore the suggestions made in that posting then you
are really fighting an uphill battle with boost and CMake. If you
choose to accept the suggestion then your life is going to be much
easier. Your Choice.
_________________________________________________________
Mike Jackson mike.jackson_at_[hidden]
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Mon, Oct 5, 2009 at 3:55 PM, motes motes <mort.motes_at_[hidden]> wrote:
> 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 mailing list
> Boost-cmake_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-cmake
>