3

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.

Community
  • 1
  • 1
andrey
  • 1,515
  • 5
  • 23
  • 39

1 Answers1

2

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.

Laser
  • 6,652
  • 8
  • 54
  • 85
  • Do you know why GNU C++ compiler's headers worked with clang but GCC's didn't? And how exactly did that help since I'm still pointing to GCC's folder for resolving headers? – andrey Feb 10 '16 at 14:12
  • @andreyg It has helped because you installed these headers on your system. As you may see in your question , in compilation process were used system's header stdind.h from gcc look for stdint on system. – Laser Feb 10 '16 at 15:30