1

I am trying to compile my project with following g++ command:

g++ -Wall -o mdaemon mdaemon-Mdaemon.o mdaemon-Rm.o mdaemon-Share.o mdaemon-SuperDaemon.o mdaemon-wmxver.o  -pthread -L/home/sunshyn/wmx_simmode/src/../cots/lib/i686-redhat-linux-gnu ..//common/libcommon.a ..//common/pm/libpm.a ..//common/br/librouter.a ..//common/br/tcp/libipc_tcp.a ..//common/applink/libapplink.a ..//common/ur/libur.a ..//common/pma/libpma.a ..//common/cma/libcma.a -lbz2 -lcurses -ldl -lpthread -lboost_program_options -lboost_thread

This results in the error displayed below:

mdaemon-Mdaemon.o(.text+0x29b6): In function `main':
: undefined reference to `boost::program_options::options_description::m_default_line_length'
mdaemon-Mdaemon.o(.text+0x29c0): In function `main':
: undefined reference to `boost::program_options::options_description::options_description(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
collect2: ld returned 1 exit status
make: *** [mdaemon] Error 1

Please let me know what is the mistake in the command?

Sunshyn
  • 43
  • 5

1 Answers1

0

The error most likely means that you did not link your application to the program_options library.

Double check your -L path (directory, in addition to the default directories, where to look for libraries).

You could also try to include the full path to the library in the list of files, without -l (e.g. g++ sources.cc ... /usr/lib/libboost_program_options.a), to link the static library.

manlio
  • 18,345
  • 14
  • 76
  • 126
  • I have tried the suggested way as well, but the error remains the same. Ofcourse, I have included "boost/program_options.hpp" – Sunshyn Apr 11 '14 at 06:15