Unix/Linux Go Back    


Gentoo Gentoo Linux is a versatile and fast, completely free Linux distribution geared towards developers and network professionals.

compiling 32 bit application on 64 bit linux(x86_64)

Gentoo


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-13-2007
uttamhoode uttamhoode is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 30 June 2009, 4:16 AM EDT
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old Unix and Linux 12-16-2007
this213 this213 is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 15 April 2010, 3:09 PM EDT
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
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"?
Sponsored Links
    #3  
Old Unix and Linux 12-16-2007
porter porter is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts
Quote:
Originally Posted by this213 View Post
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 Unix and Linux 12-17-2007
mpty mpty is offline
Registered User
 
Join Date: Feb 2004
Last Activity: 18 December 2009, 7:08 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
The gcc switch "-m32" can be used to generate 32-bit object files.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compiling old C program in Linux. yifangt Programming 1 10-25-2011 03:52 PM
gcc compiled executable not working across x86_64 linux platforms same1290 Linux 3 08-16-2008 12:17 PM
Compiling Apple Top on Linux blahblah Linux 0 05-24-2005 03:21 PM



All times are GMT -4. The time now is 10:39 AM.