Author Topic: GCC-4.4.0-MinGW Binary  (Read 37443 times)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
GCC-4.4.0-MinGW Binary
« on: April 24, 2009, 06:26:33 pm »
Hi All,

GCC-4.4.0 has been released recently. I have managed to compile it as a MinGW build. I want to share that with others. The package can be downloaded from the following links. Please download both the files and extract them to C:\MinGW folder. Then extract Win32API, MinGW Runtime, pthreads-win (If you want to use OpenMP) package to the same folder. Now you'll be able to use gcc-4.4 on Windows.

Quote
http://files.filefront.com/binutils+2191+bintarbz2/;13651013;/fileinfo.html
http://files.filefront.com/MinGW+gcc+440+bkm+1tarbz2/;13650648;/fileinfo.html

Package Details:
1) Cross-compiled binary from vanilla GCC source.
2) Only one patch was applied to fix GCC build errors. No other patch has been applied to GCC source.
3) Binutils has also been cross-compiled from vanilla BinUtils (Release 2.19.1) package
4) I've put my Blog url and my initial in the compiled binary to differentiate it from other builds.
5) gcc, g++ and gfortran binary are available. Other language compilers are not included. They are mixed together as I don't know how to create individual packages.

Important Note:
1) This is completely unsupported binary and Use it at your own risk.
2) I did very few tests by compiling few projects.
3) Notably Code::Blocks builds without any issues (but with some warning messages).

Patch:
Following patch was applied to complete the build. But it's side-effects are not explored (hope there isn't any).
Code
--- C:/gcc-4.4.0/libstdc++-v3/include/precompiled/stdtr1c++-old.h	Fri Apr 10 07:23:08 2009
+++ C:/gcc-4.4.0/libstdc++-v3/include/precompiled/stdtr1c++.h Sat Apr 25 00:03:58 2009
@@ -30,7 +30,7 @@
 
 #include <tr1/array>
 #include <tr1/cctype>
-#include <tr1/cfenv>
+//#include <tr1/cfenv>
 #include <tr1/cfloat>
 #include <tr1/cinttypes>
 #include <tr1/climits>
Have Fun! :)

Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCC-4.4.0-MinGW Binary
« Reply #1 on: April 27, 2009, 09:35:09 am »
Great Job!
Thanks for sharing.

I found that there are several types of *unofficial mingw package"


http://www.equation.com/servlet/equation.cmd?call=fortran

and

http://www.tdragon.net/recentgcc/

I'm not sure what's the difference between them.
 :D

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline drac

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: GCC-4.4.0-MinGW Binary
« Reply #2 on: April 27, 2009, 07:10:57 pm »
I've unpacked both MinGW-gcc-4.4.0-bkm-1.tar.bz2 and binutils-2.19.1-bin.tar.bz2 files into c:\mingw, then unpacked w32api-3.13-mingw32-dev.tar.gz and mingwrt-3.15.2-mingw32-dll.tar.gz and I've tried compiling a hello world program:

Code
#include <iostream>

int main()
{
  std::cout << "Goodbye cruel adventure world!" << std::endl;
}

I have got lots of errors complaining about missing headers, after copying this file set from an working 4.3.2 mingw distribution:

Code
c:\MinGW\include\wchar.h 
c:\MinGW\include\_mingw.h
c:\MinGW\include\wctype.h
c:\MinGW\include\sys\types.h
c:\MinGW\include\stdint.h
c:\MinGW\include\locale.h
c:\MinGW\include\ctype.h
c:\MinGW\include\errno.h
c:\MinGW\include\time.h
c:\MinGW\include\assert.h

I get this error:

Code
$ g++ hello.cpp -o hello
collect2: CreateProcess: No such file or directory
.

Somehow I'm doing something wrong.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #3 on: April 28, 2009, 08:30:21 am »
I have got lots of errors complaining about missing headers, after copying this file set from an working 4.3.2 mingw distribution:

Code
c:\MinGW\include\wchar.h 
c:\MinGW\include\_mingw.h
c:\MinGW\include\wctype.h
c:\MinGW\include\sys\types.h
c:\MinGW\include\stdint.h
c:\MinGW\include\locale.h
c:\MinGW\include\ctype.h
c:\MinGW\include\errno.h
c:\MinGW\include\time.h
c:\MinGW\include\assert.h

I get this error:

Code
$ g++ hello.cpp -o hello
collect2: CreateProcess: No such file or directory
.

Somehow I'm doing something wrong.

Extract mingwrt-3.15.2-mingw32-dev.tar.gz file to C:\MinGW directory. Get it from the following link-
Quote
http://sourceforge.net/project/downloading.php?group_id=2435&filename=mingwrt-3.15.2-mingw32-dev.tar.gz&a=57338028

This contains mingw runtime headers and libraries.
Be a part of the solution, not a part of the problem.

Offline drac

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: GCC-4.4.0-MinGW Binary
« Reply #4 on: April 28, 2009, 01:53:00 pm »
Extract mingwrt-3.15.2-mingw32-dev.tar.gz file to C:\MinGW directory. Get it from the following link-
Quote
http://sourceforge.net/project/downloading.php?group_id=2435&filename=mingwrt-3.15.2-mingw32-dev.tar.gz&a=57338028

This contains mingw runtime headers and libraries.

Right, silly me I tought that mingwrt-3.15.2-mingw32-dev.tar.gz contained only the source code to mingwm10.dll.
This fixes the header problem, but not the:

Code
$ g++ hello.cpp -o hello
collect2: CreateProcess: No such file or directory

I have set C:\MinGW-4.4.0\bin\ the first (I did one test only with this directory) in path environment variable and
then I have ran Process Monitor to see what happens.

ntvdm.exe is ran by g++.exe in the end and there it stops, if I kill ntvdm.exe then I see the collect2 error message.

I'm using cmd.exe without msys.

I guess the gcc 4.4.0 needs a patch in order to run correctly on Windows.



Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #5 on: April 28, 2009, 04:58:51 pm »
I have set C:\MinGW-4.4.0\bin\ the first (I did one test only with this directory) in path environment variable and
then I have ran Process Monitor to see what happens.

You should extract them to C:\MinGW folder. Otherwise it'd fail to execute other binaries.
Be a part of the solution, not a part of the problem.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #6 on: April 28, 2009, 06:28:04 pm »
I found that there are several types of *unofficial mingw package"

http://www.equation.com/servlet/equation.cmd?call=fortran

and

http://www.tdragon.net/recentgcc/

I'm not sure what's the difference between them.
 :D

They differ by configuration options, way it's built, optimization options, platform naming scheme, etc.
Be a part of the solution, not a part of the problem.

Offline drac

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: GCC-4.4.0-MinGW Binary
« Reply #7 on: April 28, 2009, 06:38:46 pm »
You should extract them to C:\MinGW folder. Otherwise it'd fail to execute other binaries.

Just tried it, the same behavior. Tested gcc and g++.

After some more digging I found out what was the problem.
The folder i686-pc-mingw32\bin\ had some very weird executables, containing only text like this (ar.exe):

Code
Link: bin/ar.exe

The folder i686-pc-mingw32 was part of binutils-2.19.1-bin.tar.bz2 , after deleting it everything worked
fine (also in c:\mingw-4.4.0)

Cheers!

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCC-4.4.0-MinGW Binary
« Reply #8 on: April 28, 2009, 09:43:04 pm »
Wish I was able to compile gcc... :(
How do you guys do this, it seems everybody and their grandmother can do it, only just not me...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #9 on: April 29, 2009, 06:17:38 pm »
Wish I was able to compile gcc... :(
How do you guys do this, it seems everybody and their grandmother can do it, only just not me...

May be I should write a blog post on how to compile this. For the time being, I'm explaining it in brief.

I prefer cross-compiling GCC as it's much faster (even from a VM) than CygWin or MSYS. Also my current antivirus freaks out every time I executes a script through MSYS.

1) You need a cross-compiler first. First install GMP-devel, MPFR-devel package on Linux. Then build BinUtils as-
Code
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install
Basically we need a binutils installation which can emit Windows executables on Linux.

2) Then extract mingw-runtime & runtime-devel, w32api packages to <BinUtils-Install-Dir>/i686-pc-mingw32 folder.

3) Add <BinUtils-Install-Dir> to path and configure & compile cross-gcc as-
Code
export PATH=<BinUtils-Install-Dir>/bin:$PATH
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install

4) Now build GMP and MPFR as -
Code
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install
This part you need to check the actual command to be used. Basic idea is to cross-compile them and install them to <BinUtils-Install-Dir> folder.

5) Now build GCC for MinGW as-
Code
./configure --host=i686-pc-mingw32 --target=i686-pc-mingw32 --prefix=/mingw && make

Edit 1: You can get the extract newly compiled binary by issuing the following command.
Code
make DESTDIR=<compiled-mingw-dir> install
<compiled-mingw-dir> can be any folder you want (e.g., /home/<Username>/foo). Only caveat is all your packages will be extracted to one folder. There should be a way to separate different language packages. But I don't know how to do that.

Hope this helps. :)
« Last Edit: April 29, 2009, 06:22:48 pm by Biplab »
Be a part of the solution, not a part of the problem.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: GCC-4.4.0-MinGW Binary
« Reply #10 on: April 29, 2009, 08:24:57 pm »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCC-4.4.0-MinGW Binary
« Reply #11 on: April 30, 2009, 12:32:08 pm »
Here's the build script I made out of your step-by-step description. I probably didn't understand your instructions right, because it fails too. But then again, I've never seen a gcc build not fail... so that doesn't really mean anything.
Code
BINUTILS=$PWD/crossbinutils
BUILDDIR=$PWD/build

test -d $BUILDDIR || mkdir $BUILDDIR
test -d $BINUTILS || mkdir $BINUTILS


wget --timestamping --quiet \
     ftp://ftp.gwdg.de/pub/misc/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.gz \
     http://www.mpfr.org/mpfr-current/mpfr-2.4.1.tar.gz \
     ftp://ftp.gmplib.org/pub/gmp-4.3.0.tar.gz

test -d gcc-4.4.0   || tar -zxf gcc-4.4.0.tar.gz
test -d mpfr-2.4.1  || tar -zxf mpfr-2.4.1.tar.gz
test -d gmp-4.3.0   || tar -zxf gmp-4.3.0.tar.gz


cd $BUILDDIR
../gcc-4.4.0/configure --target=i686-pc-mingw32 --prefix=$BINUTILS && make install


cd $BINUTILS
test -d i686-pc-mingw32 || mkdir i686-pc-mingw32
cd i686-pc-mingw32
wget --timestamping --quiet \
     http://switch.dl.sourceforge.net/sourceforge/mingw/mingwrt-3.15.2-mingw32-dev.tar.gz \
http://switch.dl.sourceforge.net/sourceforge/mingw/mingwrt-3.15.2-mingw32-dll.tar.gz \
     http://switch.dl.sourceforge.net/sourceforge/mingw/w32api-3.13-mingw32-dev.tar.gz
tar -zxf mingwrt-3.15.2-mingw32-dev.tar.gz
tar -zxf mingwrt-3.15.2-mingw32-dll.tar.gz
tar -zxf w32api-3.13-mingw32-dev.tar.gz


cd $BUILDDIR
export PATH=$BINUTILS/bin:$PATH


../gcc-4.4.0/configure --target=i686-pc-mingw32 --prefix=$BINUTILS && make install


../gmp-4.3.0/configure  --target=i686-pc-mingw32 --prefix=$BINUTILS && make install
../mpfr-2.4.1/configure --target=i686-pc-mingw32 --prefix=$BINUTILS && make install


../gcc-4.4.0/configure --host=i686-pc-mingw32 --target=i686-pc-mingw32 --prefix=/mingw \
   --enable-threads=win32 --disable-win32-registry \
                       --enable-languages=c,c++ --with-dwarf2 \
       --disable-bootstrap \
&& make

make DESTDIR=output install
Before that, I had tried to build it following step by step what's on the gcc site using the MinGW32 cross-compiler that ships with Jaunty Jackalope (why build a cross-compiler if you have one already?). But you guessed it, it won't work :)
Of course the gcc instructions aren't helpful in any way anyway.

Martin: I've looked into the MinGW build script a few days ago, but it seemed that it was still for building 3.4.5 only (maybe I picked the wrong one too).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #12 on: April 30, 2009, 04:26:36 pm »
You are trying to build a cross-compiler (Host: Linux & Target: MinGW) before building a compatible BinUtils (Host: Linux & Target: MinGW). I believe that is the problem in your case.

Edit 1:
1) Build BinUtils (Host: Linux & Target: MinGW) and install.
2) Then add newly built <BinUtils-Path> to PATH.
3) Then start building cross-compiler. :)
« Last Edit: April 30, 2009, 04:30:31 pm by Biplab »
Be a part of the solution, not a part of the problem.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCC-4.4.0-MinGW Binary
« Reply #13 on: May 01, 2009, 01:20:13 pm »
That doesn't work either, which is not surprising.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC-4.4.0-MinGW Binary
« Reply #14 on: May 01, 2009, 01:56:25 pm »
That doesn't work either, which is not surprising.

What is the failure message and which part does fail?
Be a part of the solution, not a part of the problem.