We help IT Professionals succeed at work.

Cross compiling

demeler
demeler asked
on
I am trying to setup a cross compiler on a linux based cluster. So far I can get it to compile for a different architecture but it won't link the libraries. Here is what I did:

1. downloaded and compiled binutils for my architecture (./configure --target=sparc-linux)
2. downloaded glibc and glibc-devel RPMs for sparc (2.2.3-16) and extracted them into a seperate directory
3. copied the includes, kernel headers and libraries to /usr/local/sparc-linux
4. Relinked the libraries for their new location
5. downloaded and configured gcc-2.95.3 for my target architecture, and did make LANGUAGES="c"

After this it would compile the GNU hello world test C program, but would fail when linking with this message:

sparc-linux-gcc  -o hello hello.o version.o getopt.o getopt1.o  -L/usr/local/sparc-linux/lib/
/lib/libc.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [hello] Error 1

Thank you in advance.

Comment
Watch Question

CERTIFIED EXPERT

Commented:
gcc call ld for linking, so you need a cross-linker too

Author

Commented:
And how would I do that?

Commented:
You should note that your linker tried to reference library in /lib, not in /usr/local/sparc-linux. Did you try to modify your LIBPATH? Also, can you specify which platform you're compiling on? You compiling on linux for sparc???
CERTIFIED EXPERT
Commented:
try following options for gcc:
  -nostdlib -L -L/usr/local/sparc-linux/lib/
demeler:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.