Search code examples
clang++llvm-clang

How to get standard library c++ using clang for cross compiling


First of all: I have read all similar posts and have been looking for over a Week. The Question is not repeated and I searched a lot.

Basically i m trying to compile a simple helloWorld c++ program with docker using clang as cross compiler for raspberry pi 3.

I am using VM Ubuntu 18.04

compiler clang 8 when i cross compile the code in docker using clang:

fatal error: 'bits/c++config.h' no such file or directory ...

here is CMakeLists.txt file

cmake_minimum_required(VERSION 3.7.2)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(triple arm-linux-gnueabihf)

set(CMAKE_C_COMPILER clang)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

set(DCMAKE_CROSSCOMPILING=True)
set(DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf)
set(DLLVM_TARGET_ARCH=ARM)
set(DLLVM_TARGETS_TO_BUILD=ARM)

#executing...
project (arm_cross)
add_executable(hello hello.cpp )

i expected after invoke make to get executable file for arm


Solution

  • Solution as follow what i did Firstly backup /usr/include then move /usr/arm/include file to up. Finally run your 32 bit arm application. This step can be automated by simple shell script.