我正在運行OS X 10.11(El Captain),並且正在嘗試使用C++和boost來編譯程序。具體來說,我正在嘗試使用boost::program_options
類。下面的代碼不會編譯:無法使用Xcode成功編譯升壓
#include <iostream>
#include <boost/program_options.hpp>
int main(int argc, const char *argv[]) {
boost::program_options::options_description desc("Options");
return 0;
}
,並返回錯誤:
Undefined symbols for architecture x86_64:
"boost::program_options::options_description::m_default_line_length", referenced from:
_main in test.o
processArgs(int, char const**) in test.o
"boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
_main in test.o
processArgs(int, char const**) in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我有升壓1.58.0使用沖泡時,Xcode 7.0.1安裝。我正在使用Build Options下的Default Compiler(Apple LLVM 7.0),並在庫搜索路徑中指定了/usr/local/Cellar/boost/1.58.0/include
,在庫搜索路徑中指定了/usr/local/Cellar/boost/1.58.0/lib
。此外,我已檢查目錄以確保存在正確的文件。
任何意見將不勝感激!謝謝,如果您有任何其他問題,請告訴我。
謝謝,這解決了我的問題。出於好奇,步驟5做了什麼?它是否將任何可選文件複製到指定的路徑 - 這是否與庫有關? –
我不得不承認,我沒有閱讀我鏈接到的整篇文章 - 我只是尋找一個示例添加庫。 – Julian