LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2011, 10:00 PM   #1
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Rep: Reputation: Disabled
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?
 
Old 09-07-2011, 10:07 PM   #2
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
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?
 
Old 09-07-2011, 10:25 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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
I think if you look at the '-iprefix' output, it will point to the tree where the sysroot components are expected to be. Putting them there should make it right. On one cross compiler I have right now, I see
Code:
.........arm-rn100628ctng142-linux-gnu/arm-rn100628ctng142-linux-gnu/bin/../lib/gcc/arm-rn100628ctng142-linux-gnu/4.2.1/
The accordant sysroot tree is at the same level as the 'bin/../lib/' directory. I can do
Code:
 ls  ...........arm-rn100628ctng142-linux-gnu/arm-rn100628ctng142-linux-gnu/bin/../sys-root/usr/include/

aio.h        cursesf.h   fmtmsg.h        lastlog.h   mtd            paths.h      signal.h      termios.h
aliases.h    curses.h    fnmatch.h       libelf      nc_tparm.h     poll.h       sound         tgmath.h
alloca.h     cursesm.h   form.h          libelf.h    ncurses_dll.h  printf.h     spawn.h       thread_db.h
ansidecl.h   cursesp.h   fpu_control.h   libgen.h    ncurses.h      protocols    stab.h        tic.h
a.out.h      cursesw.h   fstab.h         libintl.h   net            pthread.h    stdint.h      time.h
argp.h       cursslk.h   fts.h           libio.h     netash         pty.h        stdio_ext.h   ttyent.h
argz.h       dirent.h    ftw.h           limits.h    netatalk       pwd.h        stdio.h       ucontext.h
ar.h         dlfcn.h     _G_config.h     link.h      netax25        rdma         stdlib.h      ulimit.h
arpa         dmalloc.h   gconv.h         linux       netdb.h        re_comp.h    string.h      unctrl.h
asm          elf.h       gelf.h          locale.h    neteconet      regex.h      strings.h     unistd.h
asm-generic  endian.h    getopt.h        malloc.h    netinet        regexp.h     stropts.h     ustat.h
assert.h     envz.h      glob.h          math.h      netipx         resolv.h     symcat.h      utime.h
bfd.h        err.h       gmp.h           mcheck.h    netpacket      rpc          sys           utmp.h
bfdlink.h    errno.h     gnu             memory.h    netrom         rpcsvc       syscall.h     utmpx.h
bits         error.h     gnu-versions.h  menu.h      netrose        sched.h      sysexits.h    values.h
byteswap.h   eti.h       grp.h           mntent.h    nfs            scsi         syslog.h      video
complex.h    etip.h      iconv.h         monetary.h  nlist.h        search.h     tar.h         wait.h
cpio.h       execinfo.h  ieee754.h       mpf2mpfr.h  nl_types.h     semaphore.h  termcap.h     wchar.h
crypt.h      fcntl.h     ifaddrs.h       mpfr.h      nss.h          setjmp.h     term_entry.h  wctype.h
ctype.h      features.h  inttypes.h      mp.h        obstack.h      sgtty.h      term.h        wordexp.h
cursesapp.h  fenv.h      langinfo.h      mqueue.h    panel.h        shadow.h     termio.h      xlocale.h
You just need to get your headers files in the right place.

What is the origin of your cross toolchain?

--- rod.
 
Old 09-07-2011, 11:41 PM   #4
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
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
 
Old 09-08-2011, 08:53 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 09-09-2011, 12:09 AM   #6
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
Oh I see, I better try crosstool-ng for building my own cross toolchain.
Thanks rod.

Jaeyong
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross Compile GLib for ARM striker07 Programming 4 04-27-2011 08:49 AM
Help to cross compile vlc to arm 4monkeys Linux - Embedded & Single-board computer 3 03-14-2011 06:33 AM
cannot compile cross-gcc for arm ecco_the_dolphin Linux - Software 1 05-24-2010 06:02 PM
Trying to cross-compile mono for ARM hal_2001 Programming 2 05-11-2010 04:18 PM
how to cross compile tslib for arm ? sunr2007 Linux - Embedded & Single-board computer 3 06-29-2009 01:41 AM


All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration