Install boost open environment on Mac

Source: Internet
Author: User

Method One:

  1. Go to the download page of the MacPorts official website (https://distfiles.macports.org/MacPorts/) Download the pkg file on the Mac system, after the download is complete, double-click, all the Way "next", to the installation press.
  2. Open a new terminal: Enter sudo port install boost, prompt for a password, enter the password of the account you are currently using (note that the terminal in the password will not have any display prompt, that is, the password will not be displayed), enter, MacPorts will be fully automated download, Install and compile part of the boost library that needs to be compiled separately. The time is a bit long, you can put it to do something else.
  3. Open Xcode, create a new project, "OS X"-"Application"-"Command line Tool", creating this kind of project.
  4. Add this precompiled directive to the main file to test # include <boost/asio.hpp>, and you will find that the header file cannot be found. This is because the new project is not configured to use the Boost library. At this point we need to click on "Project Engineering Document"-"Targets"-"buildsetting"-"Search Paths"-"header Search Paths", enter/opt/local/include, so the header file can be found, Add the library file search path, then "Search Paths"-"Library Search Paths", enter/opt/local/lib.
  5. After adding the header file and library file search directory, click Run, still cannot compile, my side is pop-up error, undefined reference to ' boost::system::system_category (), which may not be connected to the corresponding library, click "Project Project Document"-"Targets"-"Build Phases"-"Link Binary with Libraries", click on the lower side of the + sign, add Libboost_system.a, click Add Another ..., to/ Opt/local/lib Select Libboost_system-mt.a, click on the lower side of the + sign, add Libboost_filesystem.a, click Add Another ..., to/opt/local/ LIB, select Libboost_filesystem-mt.a so that two library files are added.
  6. I can finally use the Boost library here through these steps, and the ASIO tutorial example on the Boost official website can be programmed.

Install boost open environment on 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.