I am trying to cross compile a sample hello world program on ARM using clang/llvm.
i am facing some problem in linking.
clang -target arm-none-linux-gnueabi hello.c
It shows some error that "no such file or directory "stdio.h"
so to avoid the error i gave following command.
clang -target arm-none-linux-gnueabi -sysroot=/path/toolchain/ hello.c -I/path/toolchain/sysroot/usr/include/
Then i successfully over come the error, but i got the linking error. error: "no such file or directory crt1.o" "no such file or directory crti.o" i exported the library path and also gave the path in command line but nothing is working for me. i gave the following command.
clang -target arm-none-linux-gnueabi -sysroot=/path/toolchain/ hello.c -I/path/toolchain/sysroot/usr/include/ -L/path/toolchain/sysroot/usr/lib
still the same error "no such file or directory crt1.o" "no such file or directory crti.o"
Looking forward for any help. i was using clang-3.0, later i downloaded the prebuilt binaries and upgraded to clang-3.3. Thanks in advance.:)
The above question can be solved by the following command.
clang -target armv7-none-eabi -sysroot=/toolchain/path/to/sysroot/ hello.c -ccc-gcc-name arm-none-linux-gnueabi-gcc hello.c
Here target says the clang compiler to choose proper target. sysroot says the exact path to take the headers and libraries(No need to provide include and library paths)