ARM Cross-compile environment setup
Hello,
I just installed arm-linux-gnueabi-gcc for cross-compiling a code. Now I have to setup an environment that can compile with standard libraries (assuming that the arm device has the same library environment). If I try to compile #include <stdio.h> int main() { printf("hello, wrold\n"); return 0; } using arm-linux-gnueabi-gcc hello.c It says #include <stdio.h> not found How can I setup this environment? Would I have to put -I/usr/include stuffs while compiling? |
I just compiled by using
$ arm-linux-gnueabi-gcc hello.c -I/usr/include/ -L/usr/lib and it gives an error /usr/lib/gcc/arm-linux-gnueabi/4.4.5/../../../../arm-linux-gnueabi/bin/ld: cannot find crt1.o: No such file or directory /usr/lib/gcc/arm-linux-gnueabi/4.4.5/../../../../arm-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory collect2: ld returned 1 exit status which is strange because I include the library path that has crt1.o and crti.0. $ ls /usr/lib/crt* -l -rw-r--r-- 1 root root 1212 2011-01-22 08:54 /usr/lib/crt1.o -rw-r--r-- 1 root root 1012 2011-01-22 08:54 /usr/lib/crti.o -rw-r--r-- 1 root root 504 2011-01-22 08:54 /usr/lib/crtn.o any idea? |
There is a lot of configuration of a cross compiler that isn't easy to see or even understand. The header files associated with the compiler are distinct from those that probably exist is part of the native toolchain. A properly crafted compiler must not trash the hosts native toolchain, so the builder of the toolchain specifies where the sysroot tree will be. The compiler then uses that in lieu of the native toolchain component locations. You can see where this is with
Code:
/path/to/your/arm-linux-gnueabi-gcc/gcc -v --help Code:
.........arm-rn100628ctng142-linux-gnu/arm-rn100628ctng142-linux-gnu/bin/../lib/gcc/arm-rn100628ctng142-linux-gnu/4.2.1/ Code:
ls ...........arm-rn100628ctng142-linux-gnu/arm-rn100628ctng142-linux-gnu/bin/../sys-root/usr/include/ What is the origin of your cross toolchain? --- rod. |
I'm using Ubuntu 10.0.4 in x86 archi and I downloaded the following packages and install them using dpkg
- binutils-arm-linux-gnueabi_2.20.51.20100908-0ubuntu2cross1.50_i386.deb - cpp-4.4-arm-linux-gnueabi_4.4.4-14ubuntu4_i386.deb - cpp-arm-linux-gnueabi_4.4.4-9_i386.deb - gcc-4.4-arm-linux-gnueabi_4.4.4-14ubuntu4_i386.deb - gcc-4.4-arm-linux-gnueabi-base_4.4.4-14ubuntu4_i386.deb - gcc-4.5-arm-linux-gnueabi-base_4.5.1-7ubuntu1cross1.38_i386.deb - gcc-arm-linux-gnueabi_4.4.4-9_i386.deb - libc6-armel-cross_2.12.1-0ubuntu6cross1.50_all.deb - libgcc1-armel-cross_4.5.1-7ubuntu1cross1.50_all.deb - libgmp3c2_4.3.2+dfsg-1ubuntu1_i386.deb - libgomp1-armel-cross_4.5.1-7ubuntu1cross1.38_all.deb - libmpfr4_3.0.0-2_i386.deb I have several followup questions 1. I try to find /path/to/your/arm-linux-gnueabi-gcc/gcc but the only possible match in my case is the following /usr/lib/gcc/arm-linux-gnueabi/4.4.5/cc1 Does it do the same thing? 2. When I type /usr/lib/gcc/arm-linux-gnueabi/4.4.5/cc1 -v --help It gives me ... -iprefix <path> ... and looks like it is not setup properly How can I set iprefix? Do I have to change some configuration file? Thanks for the help. Jaeyong |
You can't set any of the built-in paths; they're set at build time of the compiler/toolchain. I would think that the .deb packages would be set up properly, so I'm not sure how to advise you. Have you found the header files anywhere (the ones that belong to the cross compiler, not the native compiler header)? Do you have a native compiler installed? I don't know how to inspect the .deb packages to see their contents, but I think if you were able to look in the 'libc6-armel-cross_2.12.1-0ubuntu6cross1.50_all.deb', that is probably where the headers would be. Is it possible you've not installed one or more packages related to the toolchain? Is the compiler/toolchain bin directory in your $PATH?
I've never used a cross toolchain from a distro's repository, so I'm sorry that I don't know much about their makeup. I've only ever used toolchains built with crosstool-ng. --- rod. |
Oh I see, I better try crosstool-ng for building my own cross toolchain.
Thanks rod. Jaeyong |
All times are GMT -5. The time now is 01:56 AM. |