compiling 32 bit application on 64 bit linux(x86_64)

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Old 12-13-2007
compiling 32 bit application on 64 bit linux(x86_64)

hi all,
i have a 64 bit linux machine.

$uname -a
Linux SVRDELLD30 2.6.9-42.ELsmp #1 SMP Tue Aug 15 10:35:26 BST 2006 x86_64 x86_64 x86_64 GNU/Linux

here by default gcc creates 64 bit executable. but for some reason i want to create 32bit executable.

first i want to create 32 bit object files(.o files) and then i want to link those object files.

Please suggest me suitable gcc options.

Thanks and Regards,
uttam hoode
# 2  
Old 12-16-2007
Just for the sake of saying so: You know you shouldn't be installing from source on RPM based distros, right? The proper way to do this for them is to create RPMs. If you're going to be running them on multiple platforms, just create a src.rpm, then "rpmbuild --rebuild thepackage" on each platform you need, or "rpmbuild --rebuild --target i386 thepackage" from your 64-bit system.

Next, why would you want to create 32-bit objects on a 64-bit platform? Wouldn't it make more sense to create them on a 32-bit platform? If you don't want to go through the hassle of setting up a 32 bit system, just use the installation CD for Gentoo as that should have everything you need. Also, if you're going to insist on installing things from source, I'd recommend you just go ahead and switch to Gentoo anyway.

To answer your question: Doesn't gcc create 32-bit when you do "--target=i386"?
# 3  
Old 12-16-2007
Originally Posted by this213
Next, why would you want to create 32-bit objects on a 64-bit platform?
32 bit programs are smaller and faster for programs that don't need more than 2Gig of memory. Most 64 bit processers (DEC Alpha excepted) support both 32bit and 64bit binaries, and most 64 bit operating systems support different memory models simultaneously on a process by process basis.

I've generally found that compilers on 64 bit systems build 32 bit code by default and require additional switches to produce 64 bit code. The linkers are normally able to work out what memory model the code is and will reject attempts to link code with differing models.
# 4  
Old 12-17-2007
The gcc switch "-m32" can be used to generate 32-bit object files.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Which version of Windows Vista to install with a product key? 32-bit or 64-bit? milhan Windows & DOS: Issues & Discussions 4 08-03-2017 03:00 AM
Unable to install 32 bit application on 64 bit OS poga Red Hat 2 08-14-2012 04:05 AM
How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H rrd1986 Shell Programming and Scripting 0 07-11-2012 03:30 AM
Unix flavors that run on x86, x86_64 bit processors? insomnia UNIX for Dummies Questions & Answers 23 05-04-2012 01:28 PM
Error compiling 32-bit Qt-4.7 on 64-bit Ubuntu OS royalibrahim UNIX for Advanced & Expert Users 2 01-07-2011 03:34 AM
migrating unix mp-ras 32 bit to linux suse 64 bit mrodrig UNIX for Advanced & Expert Users 1 07-05-2009 11:19 AM
Is it possible to compile 64 bit application on 32 bit machine Mandar123 Linux 7 01-08-2009 03:53 PM
boot the 32 bit kernel on a 64 bit PPC Linux machine? philrau Red Hat 0 08-13-2008 04:14 PM
Compiling 32 bit app on 64 bit kernal morrisey AIX 3 03-19-2008 07:37 PM
copying or concatinating string from 1st bit, leaving 0th bit jazz Programming 2 11-10-2005 12:38 PM