LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to compile 32bit .c .cc On 64bit x86_64 systems? (https://www.linuxquestions.org/questions/linux-software-2/how-to-compile-32bit-c-cc-on-64bit-x86_64-systems-612311/)

Leo Park 01-09-2008 06:38 AM

How to compile 32bit .c .cc On 64bit x86_64 systems?
 
Hello, guys.

I want to compile 32bit *.c and *.cc files On 64bit x86_64 systems.

But, it is not work.

---------------------------------------------------------------------------------------------------------------

bmk_mgr@ikdp101[20]: gcc --version
gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bmk_mgr@ikdp101[21]: uname -a
Linux ikdp101 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:29:47 EST 2005 x86_64 x86_64 x86_64 GNU/Linux

----------------------------------------------------------------------------------------------------------------

It just work -m64 not -m32......

bmk_mgr@ikdp101[79]: gcc -m64 -o test32 test.c
bmk_mgr@ikdp101[80]: gcc -m32 -o test32 test.c
/usr/bin/ld: crt1.o: No such file: そのようなファイルやディレクトリはありません
collect2: ld はステータス 1 で終了しました
bmk_mgr@ikdp101[198]: gcc -m32 -march=i686 -o test test.c
/usr/bin/ld: crt1.o: No such file: そのようなファイルやディレクトリはありません
collect2: ld はステータス 1 で終了しました
bmk_mgr@ikdp101[199]: gcc -m32 -march=i586 -o test test.c
/usr/bin/ld: crt1.o: No such file: そのようなファイルやディレクトリはありません
collect2: ld はステータス 1 で終了しました
bmk_mgr@ikdp101[200]: gcc -m32 -march=i486 -o test test.c
/usr/bin/ld: crt1.o: No such file: そのようなファイルやディレクトリはありません
collect2: ld はステータス 1 で終了しました
bmk_mgr@ikdp101[201]: gcc -m32 -march=i386 -o test test.c
/usr/bin/ld: crt1.o: No such file: そのようなファイルやディレクトリはありません
collect2: ld はステータス 1 で終了しました
----------------------------------------------------------------------------------------------------------------

How can I do to compile 32bit binary on 64bit OS systems?

Please help me......


Thanks and Regards,
Leo Park

weibullguy 01-09-2008 07:44 AM

Your toolchain has to be built for multilib support. Execute the following and see what you get
Code:

/lib/libc.so.6
/lib64/libc.so.6

If either one fails (I suspect the first might), then you don't have multilib support on your system.

Leo Park 01-09-2008 06:32 PM

Quote:

Originally Posted by weibullguy (Post 3016598)
Your toolchain has to be built for multilib support. Execute the following and see what you get
Code:

/lib/libc.so.6
/lib64/libc.so.6

If either one fails (I suspect the first might), then you don't have multilib support on your system.

Thanks Weibullguy!
I checked and excuted codes what you said "/lib/libc.so.6 and /lib64/libc.so.6".
I think it's no problem.

----------------------------------------------------
bmk_mgr@ikdp101[21]: pwd
/lib
bmk_mgr@ikdp101[22]: ls libc.so.6
libc.so.6@
bmk_mgr@ikdp101[23]: libc.so.6
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
Compiled on a Linux 2.4.20 system on 2004-12-20.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
linuxthreads-0.10 by Xavier Leroy
The C stubs add-on version 2.1.2.
BIND-8.2.3-T5B
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Glibc-2.0 compatibility add-on by Cristian Gafton
GNU Libidn by Simon Josefsson
libthread_db work sponsored by Alpha Processor Inc
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
bmk_mgr@ikdp101[24]: cd /lib64
bmk_mgr@ikdp101[25]: pwd
/lib64
bmk_mgr@ikdp101[26]: libc.so.6
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
Compiled on a Linux 2.4.20 system on 2004-12-20.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
linuxthreads-0.10 by Xavier Leroy
The C stubs add-on version 2.1.2.
GNU Libidn by Simon Josefsson
BIND-8.2.3-T5B
libthread_db work sponsored by Alpha Processor Inc
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
bmk_mgr@ikdp101[27]:
----------------------------------------------------

I am sorry, this time is my first time on Linux system.
I have to work to compile 32bit c and cc files on 64bit Linux OS.
Please...Help me!!
Thanks and rigards....

weibullguy 01-09-2008 10:27 PM

Do you have the glibc development files installed? The package would be named something like libc-dev or libc6-dev. There may be two, one with -i386 or something to differentiate it as the 32-bit version.

Leo Park 01-09-2008 10:57 PM

Quote:

Originally Posted by weibullguy (Post 3017382)
Do you have the glibc development files installed? The package would be named something like libc-dev or libc6-dev. There may be two, one with -i386 or something to differentiate it as the 32-bit version.

Thanks weibullguy,

--------------------------------------------------------
bmk_mgr@ikdp101[186]: rpm -qa | grep ncurses
ncurses-devel-5.4-13
ncurses-5.4-13
ncurses-5.4-13
bmk_mgr@ikdp101[187]: rpm -qa | grep glibc
glibc-devel-2.3.4-2
glibc-2.3.4-2
glibc-kernheaders-2.4-9.1.87
glibc-2.3.4-2
glibc-headers-2.3.4-2
glibc-common-2.3.4-2

--------------------------------------------------------

It is installed on my OS.
How do you think that this problem is OS's problem or gcc's problem?
What can I do for compile 32bit c files on 64bit OS?

Thanks and Regard....


All times are GMT -5. The time now is 10:31 PM.