Boost environment setup under Mac

Source: Internet
Author: User

Boost, a powerful, cross-platform, open source, and free C + + library, can learn more on its website: http://www.boost.org,C++ Standard has been continuously upgraded, now has become more and more attractive, boost development process also attracted a lot of c+ +11 new features that are more compatible with C + + 's standard library, so why not use it? Although a lot of things we can write on their own, but with the help of a stable library, can improve productivity, save programmers time, he le? Of course, not let us just call functions, pass parameters, the completion of the task on the line, if not to understand the underlying principle, it can only be called the code farm, not the programmer.

Since the development environment is based on Mac, build a development platform based on it to experience the design of the boost library beautiful and powerful bar ~:

1. First, the need to download the boost source package, can be downloaded from the official website, can also be downloaded here: boost_1_60_0.tar.bz2

2. Unzip the directory structure as follows:

    

Boos sub-directory is its source code, they are divided according to function, very clear.

3. Compile. The compiler should at least support the c++98 standard, where the GCC compiler is used, as follows:

    

4. Installation:

Perform the files under Unzip directory to configure: "./bootstrap.sh"

Execute "sudo./b2--buildtype=complete install" for the Boost all libraries installation, under Mac Install the rear file path is:/usr/local/include/boost, the library path is/usr/local/ Lib

5. Build Tool Installation

Build tools can use make, cmake, and so on, where the boost comes with the B2, which uses Jamroot to configure, manage code, and then have jamfile under each module subdirectory.

CD Tools/build

./booststrap.sh

sudo./b2 Install

6. Test the code:

    

7. Compile and run:

The directory structure is as follows:

    

The contents of the Jamroot and Jamfile files are as follows:

    

Jamroot describes the entire directory structure of the compilation rules, jamfile Description of the file execution output, such as exe,unit-test, and now need to test main.cpp, into the Te directory to execute the b2 command, output, the following directory structure:

    

As you can see, in the Jamfile declaration of Unit-test, in the execution of the B2 command also carried out the unit test, here by default generate debug version of the output file, if you want to publish, execute "B2 release". Here we see the output boost version of 106000, which can now be developed using boost.

(You can also perform "g++-o main.out main.cpp", note that you need to add-istdc++ under Ubuntu, ie: g++-o main.out main.cpp-istdc++)

Boost environment setup under Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.