Ubuntu under Boost compilation installation

Source: Internet
Author: User

Ubuntu under Boost compilation install boost install 1. Dependent installation
  1. apt-get install mpi-default-dev libicu-dev python-dev python3-Dev libbz2-Dev zlib1g-Dev
2. Visit the Boost website to download the latest Boost version 3. Unzip the download file, e.g. download the file under ~/downloads
    1. CD ~/downloads
    2. Tar--bzip2-xvf boost_1_58_0. Tar. bz2
4. Prepare for installation
  1. CD boost_1_58
  2. ./Bootstrap. SH

Generate Files B2 and Bjam compute md5sum Find Them consistent
To generate the Bjam, the above command can be provided with various options, specifically refer to the Help documentation:./bootstrap.sh--help. Where the –prefix parameter, you can specify the installation path, if not with the –prefix parameter (recommended), the default path is/usr/local/include and/usr/local/lib, respectively, storing the header files and various libraries. Once executed, Bjam will be generated and the existing script will be automatically backed up. Note that boost 1.49 will generate two files in the current directory Bjam and B2, both of which are the same

5. Compile and install boost

Once the compilation is complete, install the header file and the generated library into the specified path (–prefix)

  1. . /B2//compile Boost
  2. Sudo. /b2 Install/ /Install the generated library to the/usr/local/lib directory, the default header file under the /usr/local/include/boost directory.
6. Uninstall

Delete the files in the/usr/local/lib and/usr/local/include/boost two directories directly.

7. Test whether the installation is correct

New CPP File

    1. vim boot.cpp  
  1. #include <string>
  2. #include <iostream>
  3. #include <boost/version.hpp>
  4. #include <boost/timer.hpp>
  5. using namespace STD;
  6. int main()
  7. {
  8. Boost::timer T;
  9. cout << " Max TimeSpan: " << T.elapsed_max ()/3600 << " h " << Endl;  
  10. cout << " min TimeSpan: " << t.elapsed_min () << "s" << endl; 
  11. cout << " Now time elapsed: " << t.elapsed () << "s" << endl; 
  12. cout << "Boost version" << boost_version <<endl;
  13. cout << "boost lib version" << boost_lib_version <<endl;
  14. return 0;
  15. }

Compile

  1. g+ + boot. Cpp-o Boot
  2. ./Boot

Results are displayed after successful compilation, and the last two lines print the boost version

  1. Max TimeSpan: 2.56205e+09H
  2. min TimeSpan: 1e-06S
  3. Now time elapsed: 0.000121S
  4. Boost version106300
  5. Boost Lib Version1_63

Ubuntu under Boost compilation installation

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.