Home > Linux, Programming > Cross Compiling Boost C++ Libraries for ARM

Cross Compiling Boost C++ Libraries for ARM

Boost provides free peer-reviewed portable C++ source libraries. Ten Boost libraries are already included in the C++ Standards Committee’s Library Technical Report and will be in the new C++11 Standard.

The Boost C++ libraries are already included in popular Linux and Unix distributions such as Fedora, Debian, Ubuntu and NetBSD and are used by projects such as Python, Xibo, Civilization IV, etc..

Here are the steps to cross-compile Boost C++ libraries for arm using arm-linux-guneabi-g++:

  1. Download the source code:
    wget http://sourceforge.net/projects/boost/files/boost/1.47.0/boost_1_47_0.tar.bz2/download
  2. Extract the source code:
    mv download boost.tar.bz2
    tar xjvf boost.tar.bz2
    cd boost_1_47_0/
  3. Bootstrap the code:
    ./bootstrap.sh
  4. Modify the configuration file (project-build.jam) to use the ARM toolchain by replacing the line with “using gcc” by:
    using gcc : arm : arm-linux-gnueabi-g++ ;
  5. Install the python development package:
    sudo apt-get install python-dev
  6. Build and install the boost libraries:
    ./bjam install toolset=gcc-arm --prefix=~/edev/beagleboard/libs --disable-long-double -sNO_ZLIB=1 -sNO_BZIP2=1

This was tested in Ubuntu 11.04 (natty) and 10.04 LTS with linaro g++ toolchain.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Categories: Linux, Programming Tags: C/C++, arm, boost, cross-compilation, ubuntu
  1. vincent
    November 15th, 2011 at 14:35 | #1

    Hello,I am following your step cross compile boost for mips.
    I have some questions:
    1.The last step is to ./bjam install toolset=gcc-arm….
    I don’t know how to set toolset in my environment,I use mips64-octeon-linux-gnu-g++/gcc.I try several times use gcc-mips or mips64-octeon-linux-gnu,but it failed.

    2.When I execute ./bjam install –prefix=/home/lvrainbow/request-software/octeon-boost -disable-long-double -sNO_ZLIB=1 -sNO_BZIP2=1.
    it will have some errors as following:
    /usr/include/python2.7/pyconfig.h:6:25: error: pyconfig-64.h: No such file or directory
    /usr/include/python2.7/pyport.h:849:2: error: #error “LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).”

    Didn’t you met the same errors? help me!!!Thank you very much.

  2. November 15th, 2011 at 15:11 | #2

    @vincent
    Hi Vincent,

    1.What’s inside project-build.jam (line with using gcc)?
    I suppose it should look like
    using gcc : mips : mips64-octeon-linux-gnu-g++ ;

    then I guess you may be able to use ./bjam toolset=gcc-mips …

    2. The error you get is most probably because you are building on a 32-bit machine for a 64-bit target. Make sure it uses the right python header files for your target

  3. July 13th, 2012 at 16:38 | #3

    Man you really made my day. I have been working on this since 2 days and nothing worked so far. But your post helped me to finish my problems. I was trying to use eclipse for cross compiling, but boost shared libraries were compiled for intel not arm. This helped me so much. Thank you so much.

  4. July 13th, 2012 at 17:27 | #4

    @ Yusuf Taş
    Great! I’m glad my instructions could help.

  5. Jake
    September 18th, 2012 at 08:27 | #5

    @cnxsoft
    Can you elaborate on how to get the right python header files for my target?

  6. ash
    October 18th, 2012 at 15:06 | #6

    Hi,

    My question isnt related to ARM. Its cross compilation for CN OCTEON MIPS64 platform. I have written a multithreaded code as cpp file and i am trying to cross compile using:

    [root@ash Documents]# /usr/local/Cavium_Networks/OCTEON-SDK/tools-gcc-4.3/bin/mips64-octeon-linux-gnu-g++ fourcore_2048bits.cpp -o fourcore_2048bits -lpthread

    But it gives a list of errors. Here are some of the initial errors:

    `new’ cannot appear in a constant-expression
    error: ISO C++ forbids initialization of member ‘M1′
    error: making ‘M1′ static
    invalid in-class initialization of static data member of non-integral type ‘long long unsigned int*’
    `new’ cannot appear in a constant-expression
    ISO C++ forbids initialization of member ‘M2′
    error: making ‘M2′ static
    error: invalid in-class initialization of static data member of non-integral type ‘long long unsigned int*’
    error: `new’ cannot appear in a constant-expression
    error: ISO C++ forbids initialization of member ‘ciphertext’
    error: making ‘ciphertext’ static
    error: invalid in-class initialization of static data member of non-integral type ‘long long unsigned int*’

    I have tried doing with the c++ utility as well but it keeps giving the same errors:

    [root@ash Documents]# /usr/local/Cavium_Networks/OCTEON-SDK/tools-gcc-4.3/bin/mips64-octeon-linux-gnu-c++ fourcore_2048bits.cpp -o fourcore_2048bits -lpthread

    can you please please tell me where i am wrong? i am new to linux and programming.

  7. October 18th, 2012 at 16:03 | #7

    @ash
    Try to compile your code with g++ first (not the cross-compiler) to see if it can build properly.

  8. ash
    October 19th, 2012 at 00:44 | #8

    @cnxsoft
    I did that. i have compiled the same program on my host system using g++ and its working fine.
    The problem comes when compiling for MIPS64 cavium networks OCTEON platform.

    I have been working on it since two days and I can’t proceed.

  9. ash
    October 22nd, 2012 at 13:11 | #9

    The problem is solved :)

  10. October 22nd, 2012 at 13:13 | #10

    @ash
    Great to hear. What was the problem finally and how was it solved?

  11. May 22nd, 2013 at 00:14 | #11

    @Jake
    I’m stuck here too. When I try to build it I get an error saying it can’t find arm-linux-gnueabihf/python2.7/pyconfig.h

  12. vincent
    May 22nd, 2013 at 15:16 | #12

    Hi,

    I ask about the file project-build.jam dose not exist in the boost directory i find the project-config.jam and i modefiy the line with “using gcc” by “using gcc : arm : arm-linux-gnueabi-g++ ;”

    but i get this message
    /bjam install toolset=gcc.arm –prefix=/home/out/boost –disable-long-double -sNO_ZLIB=1 -sNO_BZIP2=1
    gcc.arm.jam: No such file or directory
    /home/invitee/Bureau/boost_1_47_0/tools/build/v2/build/toolset.jam:38: in toolset.using
    rule gcc.arm.init unknown in module toolset.
    /home/invitee/Bureau/boost_1_47_0/tools/build/v2/build-system.jam:481: in process-explicit-toolset-requests
    /home/invitee/Bureau/boost_1_47_0/tools/build/v2/build-system.jam:562: in load
    /home/invitee/Bureau/boost_1_47_0/tools/build/v2/kernel/modules.jam:283: in import
    /home/invitee/Bureau/boost_1_47_0/tools/build/v2/kernel/bootstrap.jam:142: in boost-build
    /home/invitee/Bureau/boost_1_47_0/boost-build.jam:17: in module scope

  13. fercis
    August 15th, 2013 at 14:00 | #13

    Hi,
    I did whatever written in the first post, but as vincent stated project-build.jam does not exist. Instead I modified project-config.jam, (after installing Linaro Arm gcc toolchain) I observed the following error , (error: Invalid property ‘~’: unknown feature ‘–prefix’.):

    The output:

    /home/fercis/boost_1_47_0/tools/build/v2/build/property.jam:328: in validate1 from module property
    error: Invalid property ‘~’: unknown feature ‘–prefix’.
    /home/fercis/boost_1_47_0/tools/build/v2/build/property.jam:337: in property.validate from module property
    /home/fercis/boost_1_47_0/tools/build/v2/build/build-request.jam:216: in convert-command-line-element from module build-request
    /home/fercis/boost_1_47_0/tools/build/v2/build/build-request.jam:153: in build-request.from-command-line from module build-request
    /home/fercis/boost_1_47_0/tools/build/v2/build-system.jam:612: in load from module build-system
    /home/fercis/boost_1_47_0/tools/build/v2/kernel/modules.jam:283: in import from module modules
    /home/fercis/boost_1_47_0/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
    /home/fercis/boost_1_47_0/boost-build.jam:17: in module scope from module

    Do you have any comments?
    Thank you, best regards,
    fercis

  14. August 15th, 2013 at 14:44 | #14

    @fercis
    That’s because WordPress converted double dash “- -” into single dash “-”.
    So you should write something like “- -prefix”, without space.
    I’ve updated the post for that.

  1. No trackbacks yet.