Re: Problem in Install gcc on Windows XP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Dash, Santos Kumar  IN BLR SISL wrote:
> 
> Hi, 
> I want to Compile and install gcc on Windows XP. 
> Can you please tell me wat are the seqence of steps to do it. 
> Regards, 
> Santos Kumar Dash
> S I E M E N S Information Systems Ltd (SISL) 
> Work: -+91 -80- 28091562 (Dir)  ext: 4562
>  Cell: -+91 9886817129 
> mailto:Santoskumar.Dash@xxxxxxxxxxx
> 
> 

I've written a mini-howto, containing instructions on how to build the
latest gcc (currently v.4.1.1) from scratch under win32, using the
msys/mingw environment.

Readme.1st: apologize my imperfect english :/

I   - Setting up the MSYS envirnoment
II  - Installing pre-built gcc binaries
III - Creating the gcc host environment
IV  - Building and installing gcc
V   - Adding other build tools
VI  - Have fun


I - SETTING UP THE MSYS ENVIRONMENT
The first thing we'll need is a fully functional msys environment. You can
do this quickly by just downloading and installing the msys binaries
package, available at http://www.mingw.org

msys 1.0.10: http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe?download

To keep a clean understanding, I'll assume you installed msys in the c:\
root.
This way, msys is located at: c:\msys


II - INSTALLING PRE-BUILT GCC BINARIES
Now that msys is already installed, we need some version of gcc itself in
order we can build the latest version. This way, download the following
binary packages:

from GNUWin32 project:
bison:
http://prdownloads.sourceforge.net/gnuwin32/bison-2.1-bin.zip?download
flex:
http://prdownloads.sourceforge.net/gnuwin32/flex-2.5.4a-1-bin.zip?download
libiconv:
http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.9.2-1-bin.zip?download
libintl:
http://prdownloads.sourceforge.net/gnuwin32/libintl-0.14.4-bin.zip?download

from MinGW project:
win32api: 
http://prdownloads.sourceforge.net/mingw/w32api-3.7.tar.gz?download
mingw-runtime:
http://prdownloads.sourceforge.net/mingw/mingw-runtime-3.10.tar.gz?download
binutils:
http://prdownloads.sourceforge.net/mingw/binutils-2.17.50-20060824-1.tar.gz?download
gcc-core:
http://prdownloads.sourceforge.net/mingw/gcc-core-3.4.5-20060117-1.tar.gz?download

To install its, create a new directory called 'gcc' or any other you want in
the c:\ root. Then extract all files above inside this new directory.
However, for libiconv and libintl, only extract the dlls inside the
package's ./bin subdir and copy its to the c:\gcc\bin directory.

Important: after extraction, go to c:\gcc\bin and delete m4.exe (msys uses a
specific m4 build, included with msys package).

After this, add the c:\gcc\bin directory to the PATH environment variable.

Notice that gcc-g++ package is not used here, because is not necessary a c++
compiler to build gcc.

You can check if it's all right by opening msys, then typing:
# gcc -v
This should show some info about the pre-built gcc.
If working, we can go to the next step.


III - CREATING THE GCC HOST ENVIRONMENT
In order to build gcc, we need setup a host directory that will receive the
new gcc binaries and files.
This should be done before the build itself, because this host directory and
files are used during the build process.

Supposing you installed msys and the pre-built gcc under c:\, you have now
the following directory structure:

c:\
 |---folder_1
 |---folder_2
 |---gcc		<- here you installed the pre-built gcc
 |---msys		<- msys environment is installed here
 |    |---bin
 |    |---doc
 |    |---etc
 |    |---home
 |    |---mingw		<- built gcc will be installed here
 |---folder_n


Now, you'll create the host environment that will receive the new gcc build
(c:\msys\mingw).
To do this, you need install the mingw-runtime, binutils and win32 api. Just
extract the mingw-runtime and w32api packages and extract its into the
c:\msys\mingw folder. For binutils, you can either, use the binutils
binaries already downloaded or build it youself.
For the first option, just extract the binutils binary package into the
c:\msys\mingw folder.
If you want to build your own binutils binaries, please read in the next
chapter about how to do this.


IV - BUILDING AND INSTALLING GCC
In msys environment, create a work directory, where the sources and
temporary build files will be placed:
# cd /
# mkdir gcc-work && cd gcc-work
# mkdir {build,source}


*** Building binutils
If you want to build binutils from source, here are the instructions.
Otherwise, jump this section.
Download the source package:
binutils 2.17: http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2

copy/move it to the source folder (in the work directory - /gcc-work/source)
extract it:
# cd source
# tar jxf binutils-2.17.tar.bz2

go to the build directory and create a temporary directory where binutils
will be built:
# cd ../build
# mkdir binutils
# cd binutils

configure, compile and install binutils in the /mingw directory:
# ../../source/binutils-2.17/configure --prefix=/mingw --host=mingw32
--target=mingw32 --program-prefix=""
--with-lib-path=/mingw/mingw32/lib:/mingw/lib:/usr/local/lib:/lib:/usr/lib
--with-gcc --with-gnu-as --with-gnu-ld --disable-nls --disable-shared
# make  CFLAGS="-O2 -D__USE_CRTIMP -fno-exceptions" LDFLAGS=-s

flags are self-explanatory, but you can get info about configuration flags
by running the configure --help command, but is important to pay attention
in the --with-lib-path flag. it determinate where utils such ld will find
for libraries. as we are installing under /mingw directory, the first 2
paths must point to this prefix. if you want to change the prefix for some
reason, do not forgot to change this! other paths are required when
searching for libs into the msys environment (if you plan to use msys
later).

this is a time to a coffe or a beer... :)
the build process will take several minutes.

after this, just install it as the usual:
# make install


*** Building gcc
The most wanted moment has come: the gcc build itself. don't worry, nothing
surreal or cabalistic here. :)
First, download the gcc source packages - here, only c and c++ languages
will be installed, but you can obviously download other packages and modify
the command lines if you want to install other languages, such ada and java.
read about gcc configuration flags at:
http://gcc.gnu.org/install/configure.html

gcc-core: http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-core-4.1.1.tar.bz2
gcc-g++:  http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-g++-4.1.1.tar.bz2

copy/move its to the source directory, then extract:
# cd /gcc-work/source
# tar jxf gcc-core-4.1.1.tar.bz2
# tar jxf gcc-g++-4.1.1.tar.bz2

go to the build directory and create a temporary directory where gcc will be
built:
# cd ../build
# mkdir gcc
# cd gcc

configuring:
# ../../source/gcc-4.1.1/configure --prefix=/mingw --host=mingw32
--target=mingw32 --program-prefix="" --with-as=/mingw/bin/as.exe
--with-ld=/mingw/bin/ld.exe --with-gcc --with-gnu-ld --with-gnu-as
--enable-threads --disable-nls --enable-languages=c,c++
--disable-win32-registry --disable-shared --without-x --enable-interpreter
--enable-hash-synchronization --enable-libstdcxx-debug
# make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads
-fno-omit-frame-pointer -O2" LDFLAGS=-s bootstrap2
the bootstrap process is recommended in the gcc documentation, and will
produce a compiler more optimized than other that was not built in this way.
during the bootstrap, a compiler will be generated, that will compile
another compiler, that will compile another compiler and so on. the
bootstrap2 command instructs to generate 2 pre-compilers before the final
version.
obviously this process consumes much more build time, but the final result
is better. you can supress the bootstrap2 target in the make line, if you
don't want a bootstrapped compiler.

now, relax. drink a coffe, or lots of. this operation will take some long
time to complete.
after this, the happiness is complete: install your brand new gcc :)
# make install

your fresh new gcc build is now installed and ready to use. you can then
delete the work directory, as well the pre-built gcc directory. don't forgot
to add to the PATH variable the new gcc's bin directory.


V - ADDING OTHER BUILD TOOLS
Now that the new gcc binaries are already installed, we can add other
development tools to the gcc box. here, presenting gdb and make.

- installing gdb:
download the precompiled binaries of gdb:
gdb 6.3-2: http://prdownloads.sourceforge.net/mingw/gdb-6.3-2.exe?download
install the package in the c:\msys\mingw directory

i have built gdb 6.5 with success, however it does not have native support
for the pe executables. this way, the best alternative is to install the
binary package above.

- installing make:
notice that 'make' is already included with the msys package. however, if
you do not plain to work with msys later but want to use makefiles, you need
your own make binary.
 
you can install the precompiled binary package by extracting the following
package into the c:\msys\mingw folder:
http://prdownloads.sourceforge.net/mingw/mingw32-make-3.81-1.tar.gz?download

or build it youself. to do this, download the source package:
make 3.81 source: http://ftp.gnu.org/gnu/make/make-3.81.tar.bz2
copy it to the source folder in msys, then extract it:
# cd /gcc-work/source
# tar jxf make-3.81.tar.bz2

go to the /gcc-work/build and create a make's build directory:
# cd ../build && mkdir make
# cd make

build and install it:
# ../../source/make-3.81/configure --prefix=/mingw --target=mingw32
--program-prefix="" --disable-nls --disable-dependency-tracking
# make CFLAGS=-O2 LDFLAGS=-s
# make install


VI - HAVE FUN
As the title says, have fun with your latest version of gcc under win32!
Builds made with success in WinXP and Win2000, but these instructions should
work in other Win32  systems, such Win98/ME/NT/2003/Vista.
Recent snapshots for gcc 4.1 were built with success using the same approach
and steps.

Marcelo A B Slomp
mslomp^at^linuxmail^dot^org
-- 
View this message in context: http://www.nabble.com/Problem-in-Install-gcc-on-Windows-XP-tf2194467.html#a6090797
Sent from the gcc - Help forum at Nabble.com.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux