Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `boost::program_options::options_description::m_default_line_length'

I am trying to compile a code and I get the error

undefined reference to boost::program_options::options_description::m_default_line_length

I use g++ in Ubuntu 12.04. Although I have done some C++ programming I am new to the Linux development environment (used only IDEs previously).

So I did a basic search for this trouble, and found about some linking issues. I didn't quite understand them as I am a newbie. Reading some of those solutions confused me further. My boost library folder is in /usr/include. Some solutions says that it should be in /usr/lib. But I don't have any boost folder there.

What do I need to change?

like image 861
Picowhat Avatar asked Aug 29 '12 13:08

Picowhat


2 Answers

If you have installed boost from repo just use -lboost_program_options that will suffice.
If you installed boost libraries in some other library, you need to specify that directoty by -L/path/to/lib

In CMake you may specify set(CMAKE_CXX_FLAGS "-lboost_program_options")

However with CMake you should use

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(target ${Boost_LIBRARIES}) 
like image 82
Neel Basu Avatar answered Sep 20 '22 07:09

Neel Basu


There were changes to the <string> class in the C++11 standard which may conflict with versions of the Boost library that were compiled with a non-C++11 compiler (such as G++-4.8). Try recompiling boost or using a version of C++ compiler that was used to compile your Boost libraries.

like image 23
BlazePascal Avatar answered Sep 22 '22 07:09

BlazePascal