G ++ boost library compilation and Testing

Source: Internet
Author: User

1. downlaod boost.zip

2. Unzip xx.zip

3. Upload to Linux

4. chmod A + x Bootstrap. Sh

5../Bootstrap. Sh. If other permissions are insufficient, change them in sequence.

6. Wait for some secondes

7. Copy boost/boost to/usr/include/Boost

8. Copy boost/Stages/libs to/usr/local/lib/Boost

9. Upload CPP, compile

G ++-O boost XX. cpp

10. Run:

./Boost

CPP is as follows:

// Testboost. cpp: defines the entry point of the console application. //// # Include "stdafx. H "# include <stdio. h> // # include <boost/pool. HPP> // # include <boost/pool/object_pool.hpp> // # include <boost/container/vector. HPP> // # include <boost/ptr_container/ptr_vector.hpp> // # include <boost/container/string. HPP> // # include <boost/container/deque. HPP> // # include <boost/container/stable_vector.hpp> // # include <boost/container/map. HPP> # include <boost/container/list. HPP> // # includ E <boost/container/set. HPP> // using namespace boost; using namespace boost: container; // # define crtdbg_map_alloc // # include <stdlib. h> // # include <crtdbg. h> struct mymem {public: mymem () {A = 0; B = 0;} void set (int A, char B) {This-> A =; this-> B = B;} void Init () {A = 0; B = 0;} void print () {printf ("% d, % d \ n ", a, B);} PRIVATE: int A; char B;}; typedef object_pool <mymem> _ pool; int _ tmain (INT argc, _ tchar * argv []) {//// C // mymem * P2 = (mymem *) malloc (sizeof (mymem) + 1); // P2-> Init (); // P2-> Print (); // free (P2); // C ++ // mymem * P1 = new mymem (); // P1-> Print (); // Delete P1; // p1 = NULL; // pool <> _ basepool (sizeof (mymem); // mymem * P = (mymem *) _ basepool. malloc (); // P = new (p) mymem (); // P-> Print (); // _ basepool. free (p); // object_pool // _ pool mypool; // void * OBJ = mypool. malloc (); // mymem * mymem = new (OBJ) mymem (); // mymem-> PRI NT (); // mypool. free (mymem); // _ crtdumpmemoryleaks (); // vector <mymem> _ V1; // For (INT I = 0; I <3; I ++) // {// mymem TMP; // TMP. set (I + 10, I); // _ v1.push _ back (TMP); //} // For (INT I = 0; I <4; I ++) // {// _ V1 [I]. print (); //} // For (INT I = 0; I <3; I ++) // {// mymem TMP; // TMP. set (I + 10, I); // _ v1.insert (_ v1.begin (), TMP); // _ v1.insert (_ v1.end ()-1, TMP); //} // For (vector <mymem>: iterator it = _ v1.begin (); it! = _ V1.end (); ++ it) // {// It-> Print (); //} // vector <mymem *> _ V2; // For (INT I = 0; I <3; I ++) // {// mymem * P = new mymem (); // P-> set (I + 10, I); // _ v2.push _ back (p); //} // For (vector <mymem *> :: iterator it = _ v2.begin (); it! = _ V2.end (); ++ it) // {// (mymem *) (* It)-> Print (); /// ptr_vector // ptr_vector <mymem> _ V3; // mymem * P = new mymem (); // P-> set ); // _ v3.push _ back (New mymem (); // _ V3 [0]. print (); // string x = "123"; // printf (X. c_str (); // deque <mymem> _ V4; // For (INT I = 0; I <3; I ++) // {// mymem P; // P. set (I + 10, I); // _ v4.push _ back (p); //} // For (INT I = 0; I <3; I ++) // {// _ V4 [I]. print (); //} // _ v4.pop _ back (); // (Deque <mymem >:: iterator it = _ v4.begin (); it! = _ V4.end (); ++ it) // {// It-> Print (); //} // stable_vector <mymem> _ V5; // mymem P; // _ v5.push _ back (p); // _ V5 [0]. print (); // map /// Map <int, mymem> _ V6; // mymem P; // P. set (10, 1); // _ v6.insert (Map <int, mymem>: value_type (1, p); // For (INT I = 0; I <3; I ++) // {// _ V6 [I]; //. print (); //} // printf ("map size = % d \ n", _ v6.size (); // warning: map PTR is not fix [] OPERATOR // Map <int, mymem *> _ V7; // mymem * P = new mymem (); // P-> set (10, 1); // _ v7.insert (Map <int, mymem *>: value_type (1, p )); // For (INT I = 0; I <3; I ++) // {// _ V7 [I]-> Print (); //} // printf ("map size = % d \ n", _ v7.size (); // listlist <mymem> _ V8; _ v8.push _ back (mymem (); mymem x = _ v8.front (); X. print (); printf ("123 \ n"); getchar (); Return 0 ;}

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.