Help building one module with cross-compiler
Hi, I am trying to build boost module "log" on a raspberry PI as a dependency to another project. The RPI runs out of virtual memory during the build process, although I do limit building to just log (I think it builds some dependencies though). So I decided to cross compile it on a x86 machine with plenty of resources. I followed the instructions and built using: BUILD_CXXFLAGS="-std=gnu++11 -pthread" BUILD_CXX=arm-linux-gnueabihf-gcc ./bootstrap.sh --with-libraries=log --with-toolset=cross-cxx The build fails with the bootstrap.log showing the content below. Your advice is appreciated. thank you ubuntu@ryu:~/arm-toolkit/boost_1_71_0$ cat bootstrap.log######### Using 'cross-cxx' toolset.######arm-linux-gnueabihf-gcc --versionarm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) 4.8.3 20140303 (prerelease)Copyright (C) 2013 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ######arm-linux-gnueabihf-gcc -std=gnu++11 -pthread -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp filesys.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jambase.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp strings.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp execunix.cpp fileunix.cpp pathunix.cpp -o b2/tmp/ccFB5qkl.o: In function `(anonymous namespace)::std_thread_hardware_concurrency()':sysinfo.cpp:(.text+0x118): undefined reference to `std::thread::hardware_concurrency()'collect2: error: ld returned 1 exit status
Try to compile it with that compiler settings: g++ –std=c++14 -pthread Hint comes from here: https://www.geeksforgeeks.org/thread-hardware_concurrency-function-in-c/amp/ Sent from my iPhone
On 24.08.2019, at 20:05, Adrian C via Boost-users
wrote: undefined reference to `std::thread::hardware_concurrency()'
Thank you, but that caused the compiler to complain about an unknown option.
However, it succeeds if I replace BUILD_CXX=arm-linux-gnueabihf-gcc with BUILD_CXX=arm-linux-gnueabihf-g++.
Now I realize I don't understand the building process of boost. The result of running bootstrap.sh is some jam config files and an executable called b2, not the actual boost libraries.The resulting b2, unsurprisingly, is an ARM executable for the target platform, and can't run on the intel machine, which defeats my purpose of cross compiling in the first place (since it was b2 that caused the out of memory condition on the ARM).
So I ran bootstrap.sh _without_ the cross compiler settings and got a b2 for intel x86-64. Now I have to make b2 use the ARM toolchain (or it will build for Intel). However I can't figure out what and how to pass the cross compiler settings to b2, because it seems to expect them in a different way than bootstrap.sh did.Running ./b2 --help only offers this hint about cross compiling:
Properties:
toolset=toolset Indicate the toolset to build with.
I tried passing toolset=arm-linux-gnueabihf but that caused an error too:
arm.jam: No such file or directory/home/ubuntu/arm-toolkit/boost_1_71_0/tools/build/src/build/toolset.jam:44: in toolset.usingERROR: rule "arm.init" unknown in module "toolset".
Does anyone know how to tell b2 to use a specific toolchain? Or what I'm doing wrong.
On Sunday, August 25, 2019, 2:29:13 AM MST, Marko Stanisic
Hi, on the Boost Support page is a short description about a cross compiling process: https://www.boost.org/doc/libs/1_64_0/doc/html/bbv2/tasks.html I didn't found it actually for the current version,but that doesn't matter. On these pages are some additional informations: 1) https://stackoverflow.com/questions/29029867/cross-compile-boost-1-57-0-on-u... 2) https://github.com/Yadoms/yadoms/wiki/Cross-compile-for-raspberry-PI It seems that you are on the right way, you have to create a file "user-config.jam" inside $HOME (Windows: |%HOME%|) and put following line inside: using gcc : arm : arm-none-linux-gnueabi-g++ ; (or) [using gcc : arm : arm-linux-gnueabi-g++ ;(if it doesnt work )] then |./b2 --with-log toolset=gcc-arm link=static cxxflags=-fPIC (according to 2)| I hope that is more helpfull. On 25.08.19 19:53, Adrian C via Boost-users wrote:
Thank you, but that caused the compiler to complain about an unknown option.
However, it succeeds if I replace BUILD_CXX=arm-linux-gnueabihf-gcc with BUILD_CXX=arm-linux-gnueabihf-g++.
Now I realize I don't understand the building process of boost. The result of running bootstrap.sh is some jam config files and an executable called b2, not the actual boost libraries. The resulting b2, unsurprisingly, is an ARM executable for the target platform, and can't run on the intel machine, which defeats my purpose of cross compiling in the first place (since it was b2 that caused the out of memory condition on the ARM).
So I ran bootstrap.sh _without_ the cross compiler settings and got a b2 for intel x86-64. Now I have to make b2 use the ARM toolchain (or it will build for Intel). However I can't figure out what and how to pass the cross compiler settings to b2, because it seems to expect them in a different way than bootstrap.sh did. Running ./b2 --help only offers this hint about cross compiling:
Properties:
toolset=toolset Indicate the toolset to build with.
I tried passing toolset=arm-linux-gnueabihf but that caused an error too:
arm.jam: No such file or directory /home/ubuntu/arm-toolkit/boost_1_71_0/tools/build/src/build/toolset.jam:44: in toolset.using ERROR: rule "arm.init" unknown in module "toolset".
Does anyone know how to tell b2 to use a specific toolchain? Or what I'm doing wrong.
On Sunday, August 25, 2019, 2:29:13 AM MST, Marko Stanisic
wrote: Try to compile it with that compiler settings:
*g++ –std=c++14 -pthread * * *
Hint comes from here: https://www.geeksforgeeks.org/thread-hardware_concurrency-function-in-c/amp/
Sent from my iPhone
On 24.08.2019, at 20:05, Adrian C via Boost-users
mailto:boost-users@lists.boost.org> wrote: undefined reference to `std::thread::hardware_concurrency()'
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Adrian C
-
Marko Stanisic