<span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); ><span style= "White-space:pre" > </span> recently configured the QT environment under Linux, and the project needs to use boost libraries, There are a lot of tutorials about using the Boost library in the QT creator of Linux to compile the Boost library and Linux system, but there is not a whole tutorial, for this reason, the following are all steps:</span>
1, download boost library, version optional, suggest the latest version
Address: http://sourceforge.net/projects/boost/files/boost/1.52.0/
2. Build Boost Library under Linux
Unzip the download good boost library;
Open the terminal, CD to boost library decompression directory, such as my:/home/you neme/boost_1_52_0
Execute command sudo./bootstrap.sh (Generate boost dedicated compilation tool here)
Execute command sudo./bjam Install
Wait for the installation to complete, will be in the/usr/local/include directory to generate Boost library header file (in fact, is a copy, because in the extract of the boost file there will be boost in the header file), under/usr/local/lib compiled to generate boost library files, This is the default build path, in order to be easy to use later, you can create a new stage file in the Extract directory/home/you neme/boost_1_52_0 of Boost library, Create a new Lib file inside the stage (I am doing it under windows because of Custom), and then copy the generated library files to/home/you neme/boost_1_52_0/stage/lib;
3. Use boost library in Qt creator (for example, using the thread library)
New Console Application
The code in the main program is as follows:
#include <QtCore/QCoreApplication>
#include <boost/thread.hpp>
#include <iostream>
using namespace Std;
void Hello ()
{
cout<< "QT" <<endl;
}
int main (int argc, char *argv[])
{
Qcoreapplication A (argc, argv);
Boost::thread My_thread (&hello);
My_thread.join ();
return A.exec ();
}
Add boost header file path and library file path in the. Pro file as follows:
LIBS +=/HOME/XXX/BOOST_1_52_0/STAGE/LIB/LIBBOOST_THREAD.A
LIBS +=/HOME/XXX/BOOST_1_52_0/STAGE/LIB/LIBBOOST_SYSTEM.A
Note here, the use of Boost library in Qt must be added: (For specific reasons: http://blog.csdn.net/mangobar/article/details/52044778)
Defines +=boost_use_lib
Can be compiled and run