This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: help with installing gcc in os x please.
- From: "Andrea 'fwyzard' Bocci" <fwyzard at inwind dot it>
- To: Ben Dougall <bend at freenet dot co dot uk>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 23 Dec 2002 12:10:38 +0100
- Subject: Re: help with installing gcc in os x please.
At 21.58 22/12/2002 +0000, Ben Dougall wrote:
hiyer
Hi Ben,
I'll try to help, but I've never uses MacOS, only Dos/Win/Linux, so I don't
know if what I'm saying is meaningfull for you :-)
could someone give me a hand as to how you go about installing gcc please?
i've started to follow the installing documents but i'm not understanding them.
so far i've downloaded gcc 3.1
If you don't have a particular reason, I'd suggest you to download GCC
3.2.1, which is the latest released version.
i've got two folders in an otherwise empty folder. one is the
uncompressed/unpacked gcc 3.1 and the other is an empty folder called 'objdir'
Good. So "srcdir" would be the one where you unpacked gcc.
i'm on a mac with os x 10.2 which has apple's gcc, that comes with the
developer tools, installed. i understand all this needs to be done through
the terminal and i have navigated in the terminal to the previously
mentioned 'objdir' folder.
Just curious. What version of GCC comes with apple dev tools ?
gcc -v should tell you.
i've typed 'limit stack 800' as instructed by the host/target specific
installation notes - no error, so i assume that was successful.
Good.
also in the host/target specific notes is says:
"It's also convenient to use the GNU preprocessor instead of Apple's
during the first stage of bootstrapping; this is automatic when doing make
bootstrap, but to do it from the toplevel objdir you will need to say make
CC='cc -no-cpp-precomp' bootstrap."
i didn't understand that bit at all. hopefully it's not important.
Not sure, but you'll be "bootstrapping" anyway, so you're in the "this is
automatic when doing make bootstrap" case.
then near the top of the general configuration page it says to configure:
srcdir/configure [options] [target]
not sure what to do there. didn't get any further :/ if anyone could help
me make sense of the instructions it'd be very much appreciated.
I think a brief summary of how gcc is built could help :-)
Read it all before trying to build your GCC, I'm not too good at writing
things in the right order :-)
Step 1: Configure
The first step is the configuration: this stage sets things up to build GCC
for your particular machine and usage, eg.: if you want to use it to
compile for that same machine [native compiler] or to build binaries that
will run on a different kind of machine (the target) [cross compiler]. You
could alse make on a machine A a compiler that will run on machine B
building binaries for machine C. :-)
I assume you want to make a native Darwin compiler.
From the GCC Intructions:
"GCC has code to correctly determine the correct value for target for
nearly all native systems. Therefore, we highly recommend you not provide a
configure target when configuring a native compiler."
So we can skip the thing about the target. You'll probably get
powerpc-apple-darwin*, anyway.
While configuring, you can specify quite a lot of options to fine tune the
behaviour of the compiler you'll get.
As I don't know much about MacOS X, I just tried tu figure out things from
other (successful) buiold reports.
So I'd try to configure gcc with
cd objdir
../[dir where you unpacked gcc]/configure --enable-threads=posix
--enable-shared
If you feel lucky, you can try adding "--disable-multilib" to the configure
options, maybe it will make the bootstrap go faster.
After running this command, you should see a good length of messages like
"checking for blah blah blah: yes" or "no"... let it go on until it finishes.
Hopefully you'l get no errors :-).
Step 2: Bootstrap.
Building the compielr from the sources is a bit more complicated than
building other SW from sources. This is mainly because 1.) GCC requires a
very minimal, untrusted C compiler to build, and 2.) it (obviously) has the
ability to build itself, so let's damn use it !
Bootstrapping comes in 3 stages:
1st, the C compiler is built using the system C compiler
2nd, various front-ends (ObjC, C++, Java) are build with this minimal C
compiler, along with the necessary libraries.
3rd, everything is rebuilt with the full-fledged 2nd stage compiler.
Why this ? Because at this point, if all went smoothly, the 2nd and 3rd
level compilers should be identical.
This is checked for automatically at the end of bootstrapping. If you see
no error, it all went good, leaving you with a working compiler.
Now, to actually (try to) bootstrap GCC, you go to the objdir directory
(the same as where you run ../[...]/configure etc..), and run
make bootstrap
Cross you're finger, wait from half an hour to half a day (depending on how
fast is your machine), and beg for a working compiler...
If you get no errors, wow, you only need to intall it, now !
Looking around I found that, in order to actually build GCC, you MIGHT need
o apply a ptch to a system header.
I'm saying MIGHT because maybe this has been fixed in the latet GCC or
MacOS X release.
If while bootstrapping you get errors about some undefined types, you can
try to fix it applying this patch (stolen from other mail in this list):
--- gcc-04072002/gcc/ginclude/stddef.h Wed Jan 9 13:28:06 2002
+++ gccsrc/gcc/gcc/ginclude/stddef.h Thu Jul 4 18:37:27 2002
@@ -242,6 +242,7 @@
#ifndef _WCHAR_T_
#ifndef _BSD_WCHAR_T_
#ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
+#ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
#ifndef _WCHAR_T_DEFINED_
#ifndef _WCHAR_T_DEFINED
#ifndef _WCHAR_T_H
@@ -278,6 +279,7 @@
#ifdef _BSD_RUNE_T_
#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
typedef _BSD_RUNE_T_ rune_t;
+#define _BSD_RUNE_T_DEFINED_
#define _BSD_WCHAR_T_DEFINED_
#if defined (__FreeBSD__)
/* Why is this file so hard to maintain properly? In constrast to
@@ -295,6 +297,7 @@
#endif
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
+#endif
#endif
#endif
#endif
You just copy the text, save it in a simple text file in the [dir where you
unpacked gcc] directory, and run from the terminal (in that directory)
patch -p1 < [filename of the patch]
Now go back to the objdir directory, and issue
make clean
make bootstrap
The same thing as above about begging apply...
OK, lets assume you eventually got a working compiler. You need to install it.
This is easily done, with
make install
In this way you'll get gcc & co. in /usr/local/bin.
Depeneding on how the search path for executables is setup on you machine
(remember I know about nothing about MaxOS...), you'll automatically get
this new version of GCC. Or not. Read on...
And - hey - what if you wanted to keep BOTH GCCs, the apple one, and the
FSF one ?
Here the configure step helps us again.
In fact, it allows you to specify a different name for your brand new
compiler & tools.
I usually chose something like "gcc32", naming it along the version.
To do this , you have to run the configure stage (the first one) with the
additional flag "--program-suffix=suffix". Ie.,
adding "--program-suffix=32" will get you gcc32, g++32, etc...
adding "--program-suffix=-3.2.1" will get you gcc-3.2.1, g++-3.2.1, etc...
The choice is yours :-)
Remember, you need to do this at configure stage, before the make bootstrap
thing.
i think part of the problem is because i don't really have any previous
experience of the command line/console thing. all i've done with it is
compile c using the already installed gcc, so don't hold back with any
'simple' information for fear of patronising. - any info is going to be
appreciated.
thanks, ben.
Well, I hope I haved said enough to help you.
If I didn't, happily mail back to me or the list the errors or problem you
get :-)
Good luck,
fwyzard