簡體   English   中英

如何在OSX中安裝Boost

[英]How to install boost in OSX

我之前做過的事情:

(1)下載.tar

(2)解壓縮

(3)cd到路徑

(4)./bootstrap.sh

(5)等到:

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/Users/lvzhi107/Downloads/boost_1_57_0

The following directory should be added to linker library paths:

/Users/lvzhi107/Downloads/boost_1_57_0/stage/lib

(6)./ b2安裝

但它顯示:

...failed common.copy /usr/local/lib/libboost_wave.a...
...failed updating 65 targets...
...skipped 11349 targets...

然后我寫了一個代碼: test.cpp

#include<iostream>
#include<boost/format.hpp>
int main()
{
    boost::format("hello world");
}

使用g ++: g++ test.cpp運行它,但仍然錯誤:

test.cpp:2:9: fatal error: 'boost/format.hpp' file not found
#include<boost/format.hpp>
        ^
1 error generated.

您能告訴我如何解決嗎?

您需要在compile命令中添加include路徑的位置(這是頭文件所在的位置)。 通常,compile命令需要包含路徑,並且類似於以下內容:

g++ -I/usr/local/include test.cpp

但是,由於在步驟(5)上,上述標准包含路徑位置可能不是正確的位置:

以下目錄應添加到編譯器包含路徑:

/用戶/ lvzhi107 /下載/ boost_1_57_0

因此,在這種情況下,您可能會使用:

g++ -I/Users/lvzhi107/Downloads/boost_1_57_0 test.cpp

如果再次遇到相同的錯誤,建議您退一步並更深入地閱讀文檔,或者使用其他安裝Boost的方法,例如MacPorts。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM