andrey
andrey

Reputation: 1585

Clang cross-compilation for ARM

I'm trying to compile a file containing stdint.h for ARM (specifically Cortex-M3) using arm-none-eabi (which is a Debian's package) headers. The command is:

clang -I/usr/lib/gcc/arm-none-eabi/4.8/include \
    -target arm-none-eabi cfile.c -o cfile.o

(-mcpu, -mfpu, -mfloat-abi are left out for simplicity)

Returns an error:

In file included from cfile.c:1:
In file included from ./cfile.h:4:
In file included from /usr/lib/gcc/arm-none-eabi/4.8/include/stdint.h:9:
In file included from /usr/lib/llvm-3.5/bin/../lib/clang/3.5.0/include/stdint.h:61:
In file included from /usr/include/stdint.h:25:
/usr/include/features.h:374:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^
1 error generated.

I've been generally following this guide.

My versions:

$ clang --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)

Any ideas on how to approach solving this?

P.S.: Not a duplicate of this question.

Upvotes: 3

Views: 6479

Answers (1)

Laser
Laser

Reputation: 6960

To solve this issue you have to install g++-multilib
g++-multilib - the GNU C++ compiler, a fairly portable optimizing compiler for C++. It will install required headers.

As an answer for sysroot option (from comments section): You are absolutely right sysroot supposed to be used with cross-compilers installed from zips. It was not clear from a question which compiler you are trying to use.

Upvotes: 2

Related Questions