Re: Cross compilation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fernando Apesteguía wrote:
Ok, finally I found the solution.

First I compiled the .c files into .o objects and then I needed to run
gcc to link in this way:

gcc -o prog -m32 -march=i386 -L/usr/lib -L/lib $obj -lreadline -lncurses

with obj=`ls *.o`

I don't know why I need two steps because I couldn't do this in one
single step (it seems like if gcc doesn't bypass the proper
flags/options to ld to compile agains the 32 bit libraries)

HTH to another one,


It sounds like there is something wrong with the setup of your development environment. It all works perfectly well here. I am using RHEL, not Fedora, but I'd expect them both to behave the same in this respect.

$ gcc -m32 -o abc abc.c def.c -lm
$ file abc
abc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
$ ldd abc
        linux-gate.so.1 =>  (0xffffe000)
        libm.so.6 => /lib/tls/libm.so.6 (0x002ed000)
        libc.so.6 => /lib/tls/libc.so.6 (0x001c0000)
        /lib/ld-linux.so.2 (0x001a7000)

gcc has built a 32-bit executable, linked against the 32-bit libraries.

If I don't specify -m32:

$ gcc -o abc abc.c def.c -lm
$ file abc
abc: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped
$ ldd abc
        libm.so.6 => /lib64/tls/libm.so.6 (0x000000398f300000)
        libc.so.6 => /lib64/tls/libc.so.6 (0x000000398f000000)
        /lib64/ld-linux-x86-64.so.2 (0x000000398ee00000)

I get a 64-bit application linked against the 64-bit libraries.


So, what you are trying to do *should* work.

What commands did you use to compile and link the executable before? Of course, there could be something broken in the 32-bit development environment in 64-bit Fedora...

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@xxxxxxxxxxxx
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux