LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-07-2011, 12:21 PM   #1
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Rep: Reputation: 25
Compiling a 32-bit, local gcc, 64-bit host.


Hello all.

I've successfully compiled a local gcc(s), but now I want to have multiple versions (which is easy enough), but one in particular, I want to be 32-bit. This one eludes me.

Can anyone suggest what to do in order to compile a 32-bit version of the gcc that I want? All the other versions, 64-bit, compiled no problem.

Thanks!
 
Old 02-08-2011, 05:38 AM   #2
goodhombre
Member
 
Registered: Mar 2010
Location: Ungheni, Rep. Moldova
Distribution: Ubuntu
Posts: 77

Rep: Reputation: 18
Hi,

There is a long story how to build a 32 bit gcc when you don't have it to complete build process.
There is an embedded approach named cross-compiling.

Take a look at this :
http://www.linuxjournal.com/article/9904?page=0,0
 
Old 02-08-2011, 09:38 AM   #3
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by goodhombre View Post
Hi,

There is a long story how to build a 32 bit gcc when you don't have it to complete build process.
There is an embedded approach named cross-compiling.

Take a look at this :
http://www.linuxjournal.com/article/9904?page=0,0
Very nice article. I'll post my results.
 
Old 02-11-2011, 08:53 PM   #4
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
WARNING: I would *not* recommend the following, because while I'm an advanced *NIX user, I can't possibly comprehend the breadth of all manner of things related to compiling and programming, and GCC is an unwieldy beast.

With that warning said, I will simply say, that compiling the 32-bit GCC worked for *me*, by doing the following:

1) Create a local directory where you will install the new GCC.

# mkdir /usr/local/gcc/32

2) Always, always, always build GCC in a *separate* directory. Do *not* build GCC in it's own tree! Repeat, again and again and again, do *not* build GCC in its own tree. If it fails, your tree will be forever contaminated, and you will *never* be able to build in that tree again. *Never*! You'll have to 'make clean', and then delete the GCC directory, and start all over.

# cd /tmp
# tar xjf gcc-<version>.tar.bz2
# mkdir gcc-<version>-obj
# cd gcc-<version>-obj

3) Copy over kernel headers and system libraries to your new local directory:

# mkdir /usr/local/gcc/32/include
# cp -rL /usr/src/<linux/kernel/header>-<version>/linux/include /usr/src/<linux/kernel/header>-<version>/linux/asm /usr/lib/lib* /usr/local/gcc/32/include

4) Let the madness begin:

# CC="gcc -m32" CFLAGS="-m32" LDFLAGS="-m32" ../gcc-<version>/configure \
--prefix=/usr/local/gcc/32 --enable-languages="c,c++" --enable-threads=posix \
--enable-shared --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu \
--incldir=/usr/local/gcc/32/include
# make
# make install

The whole compile was surprisingly fast, coming in around under 10 minutes on a nice Core Duo workstation.

I got the results I wanted, and the flexibility and power of GNU/Linux never ceases to amaze me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
64-bit VirtualBox host running a single 32-bit guest, good idea? FireRaven Linux - Virtualization and Cloud 10 04-03-2010 03:21 PM
Compiling 32 bit sample program on 64 bit fedora using -m32 option pankajdev Linux - Newbie 2 10-07-2009 07:42 AM
Compilation problem when downgrading from 64-bit gcc to 32-bit gcc huyhoang3673 Linux - Software 7 08-26-2009 11:31 AM
xen virtualization host OS is 64 bit but cant install 32 bit guest OS hackintosh Linux - Server 0 12-26-2007 03:09 AM
32/64 bit libs - FC6/gcc 4.1.1 -m32 picking up 64 bit library marier Fedora 0 04-24-2007 12:57 PM


All times are GMT -5. The time now is 02:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration