我找不到鏈接錯誤使用boost :: program_options。這裏是一個示例c + +代碼:鏈接錯誤升壓:: program_options
# sample_code.cpp
#include <boost/program_options.hpp>
int main()
{
boost::program_options::options_description description("Test");
}
我也已經安裝了使用優勝美地10.10.2上的MacPorts提升1.57.0。下面是相關的庫:
/opt/local/lib/libboost_program_options-mt.a
讓我們編譯和鏈接下面的代碼:
alias g++='/opt/local/bin/g++-mp-5 -std=gnu++14 -I/opt/local/include -L/opt/local/lib'
g++ sample_code.cpp -lboost_program_options-mt
同時在連接過程失敗:
Undefined symbols for architecture x86_64:
"boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)"
ld: symbol(s) not found for architecture x86_64
有什麼想法?
如果您在別名用法中顛倒編譯器參數的順序,它是否工作?如果是這樣,http://stackoverflow.com/a/24675715/962089 – chris 2015-03-30 19:06:32
不是真的。我也嘗試過使用clang ++和CMake以及其所有與boost相關的參數,這沒有任何幫助! – 2015-03-30 19:20:37
你是什麼意思的「不是真的」?庫_does_在'.cpp'之後。 – 2015-03-30 19:26:34