In reading the gcc man page, and information from, say, AMD, I get
the impression that gcc can generate executables on an x86-64 box
that will run on a 32 bit machine. But I can't make it work.
I'm using SuSE 10.3 on a "Intel(R) Core(TM)2 CPU 4400 @ 2.00GHz
stepping 02".
The gcc man page says:
-march=cpu-type
Generate instructions for the machine type cpu-type. The choices for
cpu-
type are the same as for -mtune. Moreover, specifying -march=cpu-type
implies -mtune=cpu-type.
Trying -march=i386 gives:
cc -g -I/home/mellman/src/ulib -o cross.o -march=i386 cross.c
cross.c:1: error: CPU you selected does not support x86-64 instruction
set
cross.c:1: error: CPU you selected does not support x86-64 instruction
set
Right. That's the point...
And -march=i686 gives:
cc -g -I/home/mellman/src/ulib -o cross.o -march=i686 cross.c
cross.c:1: error: CPU you selected does not support x86-64 instruction
set
(just once this time)
On a lark (because I don't find an explanation in the man page of what
the difference with -march is), I tried -m32:
Here I get:
cc -g -I/home/mellman/src/ulib -o cross.o -m32 cross.c
In file included from /usr/include/features.h:345,
from /usr/include/stdio.h:28,
from cross.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or
directory
stubs-32.h is not on my system, and I can't find it on SuSE's site
either.
I find almost nothing about this when googling. WRT stubs-32.h, the
only thing I can find says to use different libraries (!). The response
is always that that didn't help.
It would seem that this is a pretty common requirement - I have a 64 bit
box at home and want to distribute my programs generally (like to my
virtual server, which only has 32 bits). The lack of general interest
here must indicate that I'm completely on the wrong track somehow...
Any ideas are appreciated...
install glibc-devel-32bit
regards,
lajos
Thank you. That worked. Actually, I got lost in the whirl of glibc-
devel and glibc-32bit and missed that there was also a glibc-devel-32bit.
Note for others: you will then have to install
gcc42-32bit-4.2.1_20070724-17.x86_64.rpm
libgomp (for 32 bits)
libmudflap (for 32 bits)
Now, is there an equally easy way to do the same thing for sparc?
The last time I delved into that, it seemed like I'd have to build a
special version of gcc ...
Unfortunately, linking failed. For example, here I successfully compiled
the .c file to a .o and then put the .o on my i686 machine and tried to
link it:
$ cc -g -I/home/mellman/src/ulib -o cross.o -march=i386 -m32 cross.c
$ file cross.o
cross.o: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
[ scp and switch to remote ]
$ cc -o cross cross.o
cross.o(.text+0x0): In function `_start':
: multiple definition of `_start'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crt1.o(.text+0x0):../
sysdeps/i386/elf/start.S:65: first defined here
cross.o(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crt1.o(.rodata+0x0):../
sysdeps/i386/elf/start.S:65: first defined here
cross.o(.fini+0x0): In function `_fini':
/usr/src/packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:41: multiple
definition of `_fini'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crti.o(.fini+0x0):/usr/
src/packages/BUILD/glibc-2.3/cc/csu/crti.S:12: first defined here
cross.o(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crt1.o(.rodata+0x4):../
sysdeps/i386/elf/start.S:71: first defined here
cross.o(.data+0x0): In function `__data_start':
: multiple definition of `__data_start'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crt1.o(.data+0x0):../
sysdeps/i386/elf/start.S:65: first defined here
cross.o(.data+0x4): In function `__data_start':
: multiple definition of `__dso_handle'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/crtbegin.o(.data+0x0): first
defined here
cross.o(.init+0x0): In function `_init':
/usr/src/packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:15: multiple
definition of `_init'
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../crti.o(.init+0x0):/usr/
src/packages/BUILD/glibc-2.3/cc/csu/crti.S: first defined here
collect2: ld returned 1 exit status
Here's trying to link it on the 64bit box:
cc -g -I/home/mellman/src/ulib -o cross -march=i686 -m32 cross.o
cross.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crt1.o:(.text
+0x0): first defined here
cross.o:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crt1.o:(.rodata
+0x0): first defined here
cross.o: In function `_fini':
/usr/src/packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:41: multiple
definition of `_fini'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crti.o:/usr/src/
packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:41: first defined here
cross.o:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crt1.o:
(.rodata.cst4+0x0): first defined here
cross.o: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crt1.o:(.data
+0x0): first defined here
cross.o: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/32/crtbegin.o:(.data+0x0): first
defined here
cross.o: In function `_init':
/usr/src/packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:15: multiple
definition of `_init'
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib/crti.o:/usr/src/
packages/BUILD/glibc-2.6.1/cc-nptl/csu/crti.S:15: first defined here
collect2: ld returned 1 exit status
make: *** [cross] Error 1
Okay, silly me. I left out the -c on the initial compile.
> Now, is there an equally easy way to do the same thing for sparc?
All recent versions of gcc, when configured and built on 64-bit
Solaris/SPARC, support '-m32' (default) and '-m64' out of the box.
Or is your question about Linux/SPARC?
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Where can I find glibc-devel-32bit-2.8, I can only find glibc-
devel-32bit-2.5, but my glibc-devel is 2.8 :glibc-devel-2.8-3.x86_64
.
I use fedora 9
Please don't follow-up to a completely unrelated message.
Start a new thread, with a new subject instead.
You are also completely off-topic in this group. Next time please
use one of the *linux* groups for linux-specific questions.
> Where can I find glibc-devel-32bit-2.8, I can only find glibc-
> devel-32bit-2.5, but my glibc-devel is 2.8 :glibc-devel-2.8-3.x86_64
Go to http://rpm.pbone.net/, type glibc-devel-2.8-3.i386 into the search box.