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?
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})
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With