Hi,
It seems that the boost_program_options is not found by your linker. Can you
try to manually set the lib like this :
TARGET_LINK_LIBRARIES(BaatzSegmentation -lboost_program_options OTBCommon OTBIO)
instead of
TARGET_LINK_LIBRARIES(BaatzSegmentation ${Boost_PROGRAM_OPTIONS_LIBRARY}
OTBCommon OTBIO)
and tell us what you get?
Jordi
Rémy Phelipot <[email protected]> wrote:
>
> Hello everyone,
>
> I am currently trying to compile a project using OTB 4.4.0 and Boost,
> and it seems impossible to link the project with OTB and Boost. The
> error message is:
> Linking CXX executable bin/BaatzSegmentation
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o:
> (.rodata._ZTVN5boost15program_options20invalid_option_valueE
> [_ZTVN5boost15program_options20invalid_option_valueE]+0x20): undefined
> reference to `boost::program_options::validation_error::what() const'
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o: In
> function `std::basic_string<char, std::char_traits<char>,
> std::allocator<char> > const&
> boost::program_options::validators::get_single_string<char>
> (std::vector<std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >, std::allocator<std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > > > const&, bool)':
> BaatzSegmentation.cxx:
> (.text._ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb]+0xde):
> undefined reference to
> `boost::program_options::validation_error::validation_error
> (boost::program_options::validation_error::kind_t, std::string const&,
> std::string const&)'
> BaatzSegmentation.cxx:
> (.text._ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb]+0x184):
> undefined reference to
> `boost::program_options::validation_error::validation_error
> (boost::program_options::validation_error::kind_t, std::string const&,
> std::string const&)'
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o:
> (.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x20):
> undefined reference to `boost::program_options::validation_error::what
> () const'
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o:
> (.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE]+0x20):
> undefined reference to `boost::program_options::validation_error::what
> () const'
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o:
> (.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x20):
> undefined reference to `boost::program_options::validation_error::what
> () const'
> CMakeFiles/BaatzSegmentation.dir/apps/BaatzSegmentation.cxx.o:
> (.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+0x20):
> undefined reference to `boost::program_options::validation_error::what
> () const'
> collect2: error: ld returned 1 exit status
> CMakeFiles/BaatzSegmentation.dir/build.make:224: recipe for target
> 'bin/BaatzSegmentation' failed
> make[2]: *** [bin/BaatzSegmentation] Error 1
> CMakeFiles/Makefile2:60: recipe for target
> 'CMakeFiles/BaatzSegmentation.dir/all' failed
> make[1]: *** [CMakeFiles/BaatzSegmentation.dir/all] Error 2
> Makefile:75: recipe for target 'all' failed
> make: *** [all] Error 2
>
> The content of the CMakeLists.txt file is:
> PROJECT(LSS)
> cmake_minimum_required(VERSION 2.8)
>
> FIND_PACKAGE(OTB)
> IF(OTB_FOUND)
> INCLUDE(${OTB_USE_FILE})
> ELSE(OTB_FOUND)
> MESSAGE(FATAL_ERROR
> "Cannot build OTB project without OTB. Please set OTB_DIR.")
> ENDIF(OTB_FOUND)
>
> set(Boost_USE_STATIC_LIBS OFF)
> set(Boost_USE_MULTITHREADED ON)
> set(Boost_USE_STATIC_RUNTIME OFF)
> set(BOOST_ALL_DYN_LINK ON)
> find_package(Boost COMPONENTS program_options REQUIRED)
> if(Boost_PROGRAM_OPTIONS_FOUND)
> INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
> LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
> message(STATUS "program_options not found ${Boost_LIBRARIES}")
> else()
> message(FATAL_ERROR "program_options not found")
> endif()
>
> add_executable(main main.cpp)
> target_link_libraries(main ${Boost_PROGRAM_OPTIONS_LIBRARY})
>
> #Check compiler version
> if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
> # require at least gcc 4.8
> if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
> message(FATAL_ERROR "GCC version must be at least 4.8!")
> endif()
> elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
> # require at least clang 3.2
> if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
> message(FATAL_ERROR "Clang version must be at least 3.2!")
> endif()
> else()
> message(WARNING "You are using an unsupported compiler! Compilation
> has only been tested with Clang and GCC.")
> endif()
>
> include(CheckCXXCompilerFlag)
> CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
> if(COMPILER_SUPPORTS_CXX11)
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive")
> else()
> message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11
> support. Please use a different C++ compiler.")
> endif()
>
> set(EXECUTABLE_OUTPUT_PATH bin)
>
> file(
> GLOB_RECURSE
> HEADERS
> "src/*.h"
> )
>
> file(
> GLOB_RECURSE
> TEMPLATES
> "src/*.txx"
> )
>
> file(
> GLOB_RECURSE
> SOURCES
> "src/*.cxx"
> )
>
> set(LSSS_INCLUDE_DIRS "")
> foreach(_headerFile ${HEADERS})
> get_filename_component(_dir ${_headerFile} PATH)
> list(APPEND LSSS_INCLUDE_DIRS ${_dir})
> endforeach()
>
> foreach(_templateFile ${TEMPLATES})
> get_filename_component(_dir ${_templateFile} PATH)
> list(APPEND LSSS_INCLUDE_DIRS ${_dir})
> endforeach()
>
> list(REMOVE_DUPLICATES LSSS_INCLUDE_DIRS)
>
> include_directories(${LSSS_INCLUDE_DIRS})
>
> ADD_EXECUTABLE(
> TiledBaatzSegmentation
> apps/TiledBaatzSegmentation.cxx
> ${SOURCES}
> )
>
> TARGET_LINK_LIBRARIES(TiledBaatzSegmentation $
> {Boost_PROGRAM_OPTIONS_LIBRARY} OTBCommon OTBIO )
>
> ADD_EXECUTABLE(
> TiledFLSASegmentation
> apps/TiledFLSASegmentation.cxx
> ${SOURCES}
> )
>
> TARGET_LINK_LIBRARIES(TiledFLSASegmentation $
> {Boost_PROGRAM_OPTIONS_LIBRARY} OTBCommon OTBIO)
>
> ADD_EXECUTABLE(
> BaatzSegmentation
> apps/BaatzSegmentation.cxx
> ${SOURCES}
> )
>
> TARGET_LINK_LIBRARIES(BaatzSegmentation $
> {Boost_PROGRAM_OPTIONS_LIBRARY} OTBCommon OTBIO)
>
> ADD_EXECUTABLE(
> FLSASegmentation
> apps/FLSASegmentation.cxx
> ${SOURCES}
> )
>
> TARGET_LINK_LIBRARIES(FLSASegmentation $
> {Boost_PROGRAM_OPTIONS_LIBRARY} OTBCommon OTBIO)
>
> I've created a minimal project using only the Boost library and it
> compiled successfuly, so the problem seems to be related to OTB.
>
> Do you have some advices to help me?
>
> Rémy
>
> --
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.