Boost logo

Boost Users :

Subject: [Boost-users] cross compile for arm setup (solved)
From: John Davis (davisjf_at_[hidden])
Date: 2014-10-24 13:29:54


Hello

I appreciate the assistance. Below is the script and results for building
boost with a cross compiler. It appears to work.

--------------------------

#!/bin/bash

# place this script in the $BOOST_ROOT directory and invoke it like so:
# ./doit.sh

# Clean up any stuff left over from a previous build
rm -rf /opt/xxx/boost/include
rm -rf /opt/xxx/boost/lib

# edit /opt/xxx/yyy/boost/boost_1_51_0/tools/build/v2/user-config.jam to
add the following line
# using gcc : 4.3arm : arm-linux-gnueabi-g++ : <architecture>arm
<target-os>linux ;
# edit /opt/xxx/yyy/boost/boost_1_51_0/tools/build/v2/user-config.jam to
remove the following line
# using gcc ;

# Ensure we are in host development environment and not using the cross
compiler.
#
# Later we modify path and CROSS_COMPILE variables.
# Here we are just ensuring we start properly,
# make sure our path does not use the cross compiler at beginning
export
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/java6/bin:/opt/java6/db/bin:/opt/java6/jre/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
export CROSS_COMPILE=

# In this stage, we are using the host compiler.

# setup env variable for $BOOST_DIR
# I'm not sure if this is being used, but set it just in case.
export BOOST_ROOT=/opt/xxx/yyy/boost/boost_1_51_0

# Its important that the next step is run from $BOOST_DIR/tools/build/v2
aka /opt/xxx/yyy/boost/boost_1_51_0/tools/build/v2
cd $BOOST_ROOT/tools/build/v2
# NOTE: ask if we have removed gcc and replaced gcc with cross compiler in
user-config.jam am I really
# invoking gcc-arm below? Its not in my path at this point.
./bootstrap.sh --with-toolset=gcc
echo current working directory is $PWD

# checkpoint exit
# At this point, /opt/xxx/boost is still empty.
#
# The ./bootstrap.sh script executed above in the tools/build/v2 directory
# is complete and gives the following output:
#
#Bootstrapping the build engine with toolset gcc...
engine/bin.linuxx86_64/bjam
#
#Bootstrapping is done. To build and install, run:
#
# ./b2 install --prefix=<DIR>
#
# !!! ERROR
# We can't run b2 at this point, because we don't have the cross compiler in
# our path yet. It dies looking for arm-linux-gnueabi-g++
# Furthermore, even though we were running in the tools/build/v2 directory
# the explicit path of running ./b2 in the current directory is wrong.
# Instead it should be run from the root directory.
# This command failed at this point, try it again later with different CWD
and
# different options.
#./b2 toolset=gcc install --prefix=/opt/xxx/boost
#exit

# At this point in the script, we have preconfigured the build of the
libraries using
# the cross compiler, the build tools which run on the host to build the
libraries
# are built (according to docs. where they are located is beyond me) , and
our original project-config.jam file is still in place since
# we issued bootstrap.sh in the v2 subdirectory. We need to change working
# directories back to the root.
# It builds b2 in the tools driectory. Maybe this is what the docs are
referring to above?
#cd $BOOST_ROOT
#echo current working directory is $PWD
#exit

# We are switching to the cross compiler at this point, ensure it is in the
# path first.

# Setup path so that gcc from cross compiler is first in the path
# also specify cross_compiler env variable in case its used.
#
# this will find the cross compiler for those who dont use the prefix, ie.
gcc
export PATH=/opt/arm/usr/local/arm-linux-gnueabi/bin:$PATH
# this will find the cross compiler for those who use the prefix, ie.
arm-linux-gnueabi-gcc
export PATH=/opt/arm/usr/local/bin:$PATH
# this will set the cross compiler prefix for those who use it. This export
# is not used by Boost.Build but keep it here for our app which uses boost.
export CROSS_COMPILE=arm-linux-gnueabi-

# since we installed boost.build stuff to /opt/xxx/boost
# in the step above, add that to the path for the next step as well.
# Its currently empty but maybe it needs to be set during the next step.
export PATH=/opt/xxx/boost/bin:$PATH

# build boost.build so that we can build boost or are we building boost at
this point?
#
# WARNING!!!
# Specify an install directory so that it doesn't put the results in
/usr/local/bin.
# Even if you dont specify install as an option to ./b2 it will attempt to
copy files to /usr/bin
# in the following step!
#
# /opt/xxx/boost is where we want results. Our code will this dir in
order to use boost.
# /opt/xxx/yyy/boost/boost_1_51_0 is the top of the boost src. We are
building beneath there.
#./b2 --toolset=gcc-4.3arm --prefix=/opt/xxx/boost

# hmm. I did not get any .a or .so after that last step. Try to add a
install parameter.
#./b2 toolset=gcc-4.3arm --prefix=/opt/xxx/boost --build-type=complete
--layout=versioned
# hmm. I did not get any .a or .so after that last step. Try to add a
install parameter.
# Above we use --with-toolset=, here we use just toolset=
# It was suggested to use the additional options below (i'm not sure why,
consider them later.)
# --without-python
# -sNO_BZIP2=1
./b2 toolset=gcc-4.3arm --without-python --debug-configuration
--prefix=/opt/xxx/boost --build-type=complete --layout=versioned install

# running b2 using above syntax from the tools/v2/build directory, we have
the following in the /opt/xxx/boost dir:

# the version of b2 here is x86_64
# /opt/xxx/boost/bin/b2
# /opt/xxx/boost/bin/bjam
# /opt/xxx/boost/share/boost-build/ whole subtree

cd $BOOST_ROOT
echo current working directory is $PWD
/opt/xxx/boost/bin/b2 toolset=gcc-4.3arm --without-python
--debug-configuration --prefix=/opt/xxx/boost --build-type=complete
--layout=versioned install

# At this point, we have the cross compiler in our path first. We are good
to go for building our code using boost
# with the cross compiler.

-------------------------------------------------------------

-- 
John F. Davis
6 Kandes Court
Durham, NC 27713
919-888-8358
独树一帜


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net