Gcc boost version conflict resolution diary, gccboost version diary
Problem background
Project in Ubuntu10 64-bit
Boost 1.55 is deployed in the form of a directory in the project.
The project uses the highest-Wall-Wextra-Werror-Wconversion alarm option.
It is possible to test it separately.
Because the project contains a lot of content and a large number of header files, you can only select one simple branch for testing. The problem can be reproduced. Through various guesses and tests, the final location is as follows:
After GCC push_option is used to process boost/thread, the stl container is completely abnormal [such as begin () When map <int, string> is empty ()! = End (): The insert record crashes or has an infinite loop. There are minor differences between the two machines. When there is an infinite loop, gdb attach can see that the map operation cannot be completed]. Without push_option, everything works normally.
Solution
The pre-processing result of gcc-E code is too much to be viewed, and no further detailed analysis is performed.
Since this option of gcc conflicts with the thread of boost, check the push_option description of gcc. We can see that gcc 4.4 is targeted, while the default gcc version of ubuntu is version 4.4.3 (Ubuntu 4.4.3-4ubuntu5. 1) I guess whether this implementation has some problems.
Since this is different, can we use a third-party library as a system library and copy it to the/usr/include directory in the simplest way? But this method is not practical?
Check the gcc manual, there is really this option-isystem https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Preprocessor-Options.html#Preprocessor-Options
-Isystem $ {ProjDirPath}/.../others
The final project is configured with this option for compilation.
Example
Create a project separately as follows, but it is normal
G ++-L/opt/work/lib/static-L/opt/work/lib/-o "zdemo ". /src/demo. o-lboost_system-lrt-lpthread-lboost_thread
# Include <iostream>
# Include <vector>
# Include <map>
# Pragma GCC push_options
# Pragma GCC diagnostic ignored "-Wconversion"
# Include <boost/thread. hpp>
# Pragma GCC pop_options
# Include <boost/make_shared.hpp>
# Include <boost/bind. hpp>
Using namespace std;
Class Demo {
Public:
Demo (const string & json ){
This-> rules [GET]. push_back ("hello ");
This-> rules [GET]. push_back (json );
}
Enum HttpMethod {ANY, GET, POST, PUT, DEL, OTHERS };
Typedef vector <string> tRuleContainer;
Map <HttpMethod, tRuleContainer> rules;
};
Void demoThread (){
Demo u ("world ");
Cout <u. rules. size () <endl;
}
Int main (){
Boost: shared_ptr <boost: thread> thrMon;
ThrMon = boost: make_shared <boost: thread> (boost: bind (& demoThread ));
Demo u ("world ");
Cout <u. rules. size () <endl;
ThrMon-> join ();
Return 0;
}
What is the relationship between the boost version and the gcc version when the boost library is installed in linux?
Of course this is related to the GCC version.
Consider the support for some new features and select a newer version of GCC
Use gcc to compile boost in Windows
Add the-a option after bjam to remove the options of install and-without-python.