Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

351
Views
Clang cross-compile for Raspberry pi 3B+

I have been trying to set up a clang cross-compiler toolchain that will compile C/C++ host x86-64-linux-gnu to target arm-linux-gnueabihf. The output binary is intended to run on a raspberry pi 3B+ with armv7 cortex-53a CPU. The raspberry pi OS is the debian-buster equivalent of Raspian, so the default clang in apt is clang-7.0.1.

I am hoping to accomplish a clang cross-compiler, that can be invoked with

clang++ hello_world.cpp

And by default compiles and links with the correct arm-linux-gnueabihf include and library paths. The linker to use is not important to my end.

I started off by following the guide at https://solarianprogrammer.com/2019/05/04/clang-cross-compiler-for-raspberry-pi/, and TLDR; it downloads the llvm-project with the appropriate version (7.0.1), builds LLVM, clang, compiler-rt, lld, libunwind and polly with cmake and ninja, using cmake flags:

-DCMAKE_BUILD_TYPE=Release
-DLLVM_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/cross_armhf_clang_7
-DCMAKE_CROSSCOMPILING=True -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf 
-DLLVM_TARGET_ARCH=ARM 
-DLLVM_TARGETS_TO_BUILD=ARM

But when trying to compile the libcxxabi and libcxx with the newly built clang, it does not find the correct libstdc++:

 CMake Error at /usr/local/cross_armhf_clang_7/lib/cmake/llvm/CheckCompilerVersion.cmake:38 (message):
   Host Clang must be able to find libstdc++4.8 or newer!
Call Stack (most recent call first):
  /usr/local/cross_armhf_clang_7/lib/cmake/llvm/HandleLLVMOptions.cmake:9 (include)
  cmake/Modules/HandleOutOfTreeLLVM.cmake:97 (include)
  cmake/Modules/HandleOutOfTreeLLVM.cmake:140 (configure_out_of_tree_llvm)
  CMakeLists.txt:29 (include)

Here I am using the cmake flags:

-DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=/usr/local/cross_armhf_clang_7 
-DLLVM_TARGETS_TO_BUILD=ARM 
-DCMAKE_C_COMPILER=/usr/local/cross_armhf_clang_7/bin/clang 
-DCMAKE_CXX_COMPILER=/usr/local/cross_armhf_clang_7/bin/clang++

I have also tried to just compile a simple hello-world.cpp with clang-10 on my desktop with the installed arm-linux-gnueabihf binutils, gcc, etc in my sysroot

clang++ --target=arm-linux-gnueabihf hello-world.cpp

which gives me

/usr/bin/../lib/gcc-cross/arm-linux-gnueabihf/9/../../../../include/c++/9/string:38:10: fatal error: 'bits/c++config.h' file not found

I have also tried using the guides at the llvm webpage for cross-compiling with clang and building libc++, but with no luck.

Any suggestions as to what I can do to solve this?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!