安装包:
下载路径:
http://sourceforge.net/projects/boost/files/boost/1.55.0/
下载 boost_1_55_0.zip
1.首先运行boost解压目录下的
unzip boost_1_55_0.
zip
2.运行安装包自带的脚本:
./bootstrap.
sh
2.修改生成的project-config.jam文件,具体可以参照
修改:(共五处)
using gcc : arm : arm-none-linux-gnueabi-gcc ;
option.set prefix :(交叉编译器所在位置);
option.set exec-prefix :(交叉编译器所在位置)/bin ;
option.set libdir :(交叉编译器所在位置)/lib ;
option.set includedir :(交叉编译器所在位置)/include ;
修改后配置文件如下:
1 # Boost.Build Configuration
2 # Automatically generated by bootstrap.sh
3
4 import option ;
5 import feature ;
6
7 # Compiler configuration. This definition will be used unless
8 # you already have defined some toolsets in your user-config.jam
9 # file.
10 if ! gcc in [ feature.values <toolset> ]
11 {
12 using gcc : arm : arm-linux-gcc ;
13 }
14
15 project : default-build <toolset>gcc ;
16
17 # Python configuration
18 using python : 2.6 : /usr ;
19
20 # List of --with-<library> and --without-
<library>
21 # options. If left empty, all libraries will be built.
22 # Options specified on the command line completely
23 # override this variable.
24 libraries = ;
25
26 # These settings are equivivalent to corresponding command-line
27 # options.
28 option.set prefix : /usr/local/arm/4.3.3 ;
29 option.set exec-prefix : /usr/local/arm/4.3.3/bin ;
30 option.set libdir : /usr/local/arm/4.3.3/lib ;
31 option.set includedir : /usr/local/arm/4.3.3/include ;
32
33 # Stop on first error
34 option.set keep-going : false ;
3.测试编译效果
./bjam stage --layout=tagged --build-type=complete
还可以加(link=shared runtime-link=shared threading=multi)等编译参数
生成的动/静态库在boost/stage/lib 目录下
4.将boost文件夹拷贝到arm-linux-gcc 的include目录下;
如何知道arm-linux-gcc 的头文件以及库文件路径? 采用shell命令:
echo 'main(){}' | arm-linux-
gcc -E -v -
测试文件BoostTest.
cpp如下:
#include
#include
int main()
{
int a = boost::lexical_cast<int>("1008611");
std::cout << a <<std::endl;
return 0;
}
编译命令:
arm-linux-g++ BoostTest.cpp -L ../stage/lib/ -o test
拷贝test到arm上可以测试是否能运行;