最近我開始使用Windows上的Boost進行項目工作。它需要是跨平臺的,所以我也在Mac上安裝了它。不幸;每當我將它添加到Xcode項目時,它都會給我帶來大量的鏈接錯誤和轉換警告。Mac上的Boost鏈接器錯誤(OSX 10.10.02 | Xcode 6.1.1)
實例鏈接器錯誤之一:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from: ___cxx_global_var_init2 in main.o boost::asio::error::get_system_category() in main.o boost::system::error_code::error_code() in main.o "boost::system::generic_category()", referenced from: ___cxx_global_var_init in main.o ___cxx_global_var_init1 in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
轉換的警告的一個實例:
In file included from /usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_types.hpp:16: /usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_duration.hpp:24:21: warning: implicit conversion loses integer precision: 'long' to 'hour_type' (aka 'int') [-Wshorten-64-to-32] time_duration(h,0,0)
我試了好幾種安裝方法和配置方法,但它仍然不會工作。
這是我的步驟:
- 編譯升壓或升壓得到的編譯版本。
- 創建一個XCode項目。
- 在主類中輸入this示例代碼。
- 將標題和庫路徑添加到Xcode項目文件。
- 構建。
編譯選項我曾嘗試:
- 從源代碼使用the official guide編譯。
- 使用幾個腳本從源代碼編譯我在這裏找到了Stackoverflow。
- 安裝brew包管理器並下載帶有二進制文件的包。
配置選項我曾嘗試:
- 設置爲/usr/local/Cellar/boost/1.57.0/include或等同物和 的報頭搜索路徑設定庫搜索路徑到/ usr /local/Cellar/boost/1.57.0/lib或等價物。
- 只設置標題搜索路徑而不設置庫路徑。
- 選項1但遞歸(導致更多錯誤)。
如果有人能指出我正確的方向,我將非常感激。我認爲這是與Xcode相關的,因爲所有的編譯版本都給我提供了相同的錯誤。