Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

364
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda