Cannot find C++ library when linking, error compliling the `boost::program_options` example

后端 未结 1 1155
粉色の甜心
粉色の甜心 2021-02-18 18:45

I am trying to compile the multiple_sources.cpp to compile on my computer. I am running Xubuntu Lucid Lynx fully updated.

It will compile without issue with g++ -c

相关标签:
1条回答
  • 2021-02-18 19:06

    The -l param is wrong; get rid of the lib pre-fix and use -lboost_program_options.

    The linker expects all libraries to begin with lib, and for you to leave that off when specifying the library.

    You could also include the full path to the library in the list of files, without -l (e.g. g++ multiple_sources.cpp /usr/lib/libboost_program_options.so), but for system libraries, it's better to follow convention; they aren't always installed in /usr/lib.

    0 讨论(0)
提交回复
热议问题