Search code examples
gccboostarmembeddedcross-compiling

Boost library cross compilation to embedded ARM with b2 builder error


I'm getting an error when I'm trying to build boost libraries for ARM on Windows. I'm using gcc "arm-linux-gnueabi" cross compiler that works just fine on the Eclipse ARM DS-5 platform. But I need to build Boost libraries manually for ARM first in order to use them in Eclipse.

I followed these instructions for cross-compilation but there is still an error occurring when I run b2 toolset=gcc-arm target-os=linux in windows cmd:

C:\boost\boost_1_82_0>b2 toolset=gcc-arm target-os=linux
C:/boost/boost_1_82_0/tools/build/src/util\numbers.jam:23: in numbers.check from module numbers
error: arm in arm
error: is not a number
C:/boost/boost_1_82_0/tools/build/src/build\version.jam:110: in version.version-compatible from module version
C:/boost/boost_1_82_0/tools/build/src/tools\common.jam:1132: in common.find-compiler from module common
C:/boost/boost_1_82_0/tools/build/src/tools\gcc.jam:165: in gcc.init from module gcc
C:/boost/boost_1_82_0/tools/build/src/build\toolset.jam:44: in toolset.using from module toolset
C:/boost/boost_1_82_0/tools/build/src\build-system.jam:543: in process-explicit-toolset-requests from module build-system
C:/boost/boost_1_82_0/tools/build/src\build-system.jam:610: in load from module build-system
C:/boost/boost_1_82_0/tools/build/src/kernel\modules.jam:294: in import from module modules
C:/boost/boost_1_82_0/tools/build/src/kernel/bootstrap.jam:135: in module scope from module

Tried all sorts of editing the user-config.jam, editing the gcc PATH and the b2 command, but none of it helped.

I created my own "user-config.jam" in boost directory root and added this line into it: using gcc : arm : arm-linux-gnueabi-g++ ;

The gcc compiler is added to PATH, this is the output of gcc -v in cmd:

C:\boost\boost_1_82_0>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/src/gcc-linaro-4.8-2014.04/configure --build=i686-build_pc-linux-gnu --host=i586-host_pc-mingw32msvc --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/.build/arm-linux-gnueabihf/build/static --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-gold --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-win32/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long --with-mode=thumb --with-float=hard
Thread model: posix
gcc version 4.8.3 20140401 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04)

This is how Eclipse platform uses the cross compiler. Everything works fine in Eclipse.

I will be thankful for any ideas and comments.


Solution

  • This may be related to the way you are specifying the C++ compiler to be used in your configuration file.

    The following procedure is working for me, although using a different version of g++, but this is highly likely irrelevant to your current issue: Assuming the Download Visual Studio Tools are already installed and in your executable path:

    • Downloading boost_1_82_0.7z:
      certutil.exe -urlcache -split -f " https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.7z" boost_1_82_0.7z
    • Extracting it the archive file:
      7z x boost_1_82_0.7z
    • One the extraction is completed, change your current directory to boost_1_82_0
    • Build b2:
      bootstrap.bat
    • Create user-config.jam in the boost_1_82_0 directory with the following content - you obviously have to use the path for your g++ in this file:
      using gcc : arm : D:\\opt\\arm\\10\\gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-linux-gnueabihf\\bin\\arm-none-linux-gnueabihf-g++ ;
    • Build boost:
      b2 toolset=gcc-arm target-os=linux --user-config=user-config.jam

    After some time, the following message should be displayed:

    
    The Boost C++ Libraries were successfully built!
    
    The following directory should be added to compiler include paths:
    
        D:\boost_1_82_0
    
    The following directory should be added to linker library paths:
    
        D:\boost_1_82_0\stage\lib
    
    
    D:\boost_1_82_0>
    

    Verifying the libraries were built:

    D:\boost_1_82_0>  dir D:\boost_1_82_0\stage\lib\*.a
    D:\boost_1_82_0>  dir D:\boost_1_82_0\stage\lib\*.a
     Volume in drive D is DATA
     Volume Serial Number is 0E12-BCA2
    
     Directory of D:\boost_1_82_0\stage\lib
    
    2023-07-08  04:28 PM             6,052 libboost_atomic-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM            98,968 libboost_chrono-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM           109,184 libboost_container-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM             2,628 libboost_context-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM           191,652 libboost_contract-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM            16,618 libboost_coroutine-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM             1,334 libboost_date_time-gcc-mt-a32-1_82.a
    2023-07-08  04:31 PM             1,526 libboost_exception-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM           207,268 libboost_fiber-gcc-mt-a32-1_82.a
    2023-07-08  04:28 PM           210,180 libboost_filesystem-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM           847,206 libboost_graph-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM            92,860 libboost_iostreams-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM           448,546 libboost_json-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM         1,468,700 libboost_locale-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM         2,504,078 libboost_log-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM         2,390,400 libboost_log_setup-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            87,236 libboost_math_c99-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            87,884 libboost_math_c99f-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            87,748 libboost_math_c99l-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           492,848 libboost_math_tr1-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           500,294 libboost_math_tr1f-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           495,664 libboost_math_tr1l-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            16,602 libboost_nowide-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           130,772 libboost_prg_exec_monitor-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           918,610 libboost_program_options-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            35,214 libboost_random-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM           592,044 libboost_regex-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM         1,206,106 libboost_serialization-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM             8,344 libboost_stacktrace_basic-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM             2,346 libboost_stacktrace_noop-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM             1,308 libboost_system-gcc-mt-a32-1_82.a
    2023-07-08  04:27 PM         1,884,314 libboost_test_exec_monitor-gcc-mt-a32-1_82.a
    2023-07-08  04:29 PM           262,874 libboost_thread-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM            15,038 libboost_timer-gcc-mt-a32-1_82.a
    2023-07-08  04:31 PM            87,964 libboost_type_erasure-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM         1,868,546 libboost_unit_test_framework-gcc-mt-a32-1_82.a
    2023-07-08  04:31 PM           557,462 libboost_url-gcc-mt-a32-1_82.a
    2023-07-08  04:31 PM         4,344,190 libboost_wave-gcc-mt-a32-1_82.a
    2023-07-08  04:30 PM           823,380 libboost_wserialization-gcc-mt-a32-1_82.a