0

I am using linux and my CMakeList.txt file is

 cmake_minimum_required(VERSION 2.8) set(Boost_INCLUDE_DIR /usr/local/include) set(Boost_LIBRARY_DIR /usr/local/lib) set(CMAKE_CXX_FLAGS "-lboost_program_options") find_package(Boost 1.55 COMPONENTS system program_options filesystem REQUIRED) include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIR}) if(NOT Boost_FOUND) message(FATAL_ERROR "boost not found") endif() add_executable(main main.cpp) target_link_libraries( main ${Boost_LABRARIES} ) 

and i am getting the following errors. I am working on it from two days and now i am sick of it . Can any body help me please.cmake_

Errors:

 main.cpp:(.text+0x1d): undefined reference to `boost::program_options::options_description::m_default_line_length' main.cpp:(.text+0x28): undefined reference to `boost::program_options::options_description::m_default_line_length' main.cpp:(.text+0x6a): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)' collect2: error: ld returned 1 exit status make[2]: *** [main] Error 1 make[1]: *** [CMakeFiles/main.dir/all] Error 2 make: *** [all] Error 2 

1 Answer 1

1

You have a typo: Boost_LABRARIES should be Boost_LIBRARIES. You should also remove the SET(CMAKE_CXX_FLAGS ... line, that's never needed to link to libraries when using CMake (and it's non-portable anyway.)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.