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

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux