click Download on the homepage to download the SourceForge page. The latest version is boost_000033_1. There are multiple
file formats available for download (package .exe,
.tar.gz, etc.) with the same content, all of which are boost_000033_1 Source Code . Download and decompress the package. (assume the directory is/home/yjguo
/boost_000033_1 ).
most of the content in boost can be directly used by the source Code , while thread needs to compile the corresponding Library first.
Linux:
redhat9.0 is installed by default.
1. compile jam (jam is the basis for compiling other libraries)
enter the/home/yjguo/boost_1_33_1/tools/build/jam_src directory
Run. /build. SH:
after running, the bin is displayed. linuxx86 directory, the bjam we need is under this directory.
the build. Sh script automatically detects GCC and calls GCC to compile bjam. (A lot of information is mentioned in the index.html file under the jam_srcdirectory)
2. compile the thread library
go to the/home/yjguo/boost_000033_1 directory.
run the program. /tools/build/jam_src/bin. linuxx86/bjam -- With-thread stage (only compile thread Library)
after compilation, the result is in the/home/yjguo/boost_1_33_1/bin/Boost/libs/thread/build directory (including debug
/relase,
. a /. in addition, because we use the stage option during compilation, therefore, all the results will be copied to the/home/yjguo/boost_1_33_1
/stage/lib directory.
3. Prepare to use the thread library
select the compiled thread dynamic library (. So share object ).
copy the libboost_thread-gcc-mt-1_33_1.so.1.33.1 to the/usr/lib/directory
copy the libboost_thread-gcc-mt-d-1_33_1.so.1.33.1 to the/usr/lib/directory
to/usr//lib directory run
ln-s libboost_thread-gcc-mt-1_33_1.so.1.33.1 libboost_thread-gcc-mt-1_33_1.so
Ln-s libboost_thread-gcc-mt-d-1_33_1.so.1.33.1 libboost_thread-gcc-mt-d-1_33_1.so
4. Use the thread Library
Create the main. cpp file in the/home/yjguo directory with the following content:
# Include <boost/thread. HPP>
# Include <iostream>
Void Hello ()
{
STD: cout <"Hello world, I'm a thread! "<STD: Endl;
}
Main ()
{
Boost: thread thrd (& Hello );
Thrd. Join ();
}
Run g ++-I/home/yjguo/boost_1_33_1-pthread-lboost_thread-gcc-mt-1_33_1 main. cpp to get the. Out file.
./A. Out to run.