简体   繁体   中英

How to install boost in OSX

What I have done before:

(1) download .tar

(2) unzip

(3) cd to the path

(4) ./bootstrap.sh

(5) wait until:

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 install

but it shows :

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

then I wrote a code: test.cpp

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

run it using g++: g++ test.cpp but it still wrong:

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

Could you tell me how to solve it?Thanks.

You need to add the location of the include path in the compile command (this is where header files would be located). Often the compile command needs to have the include path, and would be similar to this:

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

However, the standard include path location above might not be the correct location, since on step (5):

The following directory should be added to compiler include paths:

/Users/lvzhi107/Downloads/boost_1_57_0

So in that case you would likely use:

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

If you encounter the same error again it might be recommended to step back and read the documentation more in depth, or perhaps use another means of installing boost such as MacPorts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM