Install and use boost on Mac

Source: Internet
Author: User

Method 1:

  1. Go to the macports official website download page (https://distfiles.macports.org/MacPorts/) to download the MAC system PKG file, after the download is complete, double-click, one way [next], to install.
  2. Open a new terminal: Enter sudo port install boost, prompt to enter the password, enter the password of your current account (note that there will be no display prompt when you enter the password in the terminal, that is, the entered password is not displayed), press enter, macports will be fully automated download, install and compile Part of the boost library that needs to be compiled separately. It takes a long time. You can do something else.
  3. Open xcode and create a project. Choose OS X> Application> command line tool to create the project.
  4. Add the pre-compiled command to the main file for testing # include <boost/ASIO. HPP>. The header file cannot be found. This is because the newly created project is not configured to use the boost library. Click project files> targets> buildsetting> search.
    Paths]-"[header search paths], enter/opt/local/include, so that the header file can be found, and then add the library file search path, choose search paths> library search paths and enter/opt/local/lib.
  5. After the header file and library file search directory are added, click "run" and the compilation fails. An error is displayed on my side. undefined reference to 'boost: System: system_category (), this may be because the corresponding database cannot be connected. Click project files> targets> build.
    Phases-"[LINK binary with libraries], click the plus sign on the lower side, add libboost_system.a, and click Add another ..., to/opt/local/lib, select the libboost_system-mt.a, click the + number next to the side, add libboost_filesystem.a, and click Add
    Another..., to/opt/local/lib, select the libboost_filesystem-mt.a to add two library files.
  6. I can use the boost library through these steps. The Tutorial example of ASIO on the official boost website can be programmed.

Method 2:

  • I started using this method based on the official website of the boost library. However, I encountered some problems and then used this method.

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.