Author Topic: Anyone know of a minGW GCC Installation(Build from source) Tutorial?  (Read 4402 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7680
    • My Best Post
I have been trying to build GCC using minGW GCC and for minGW and have been having issues.
Anyone know of an Installation Tutorial? Wiki Installation Tutorial?

If I figure it out would it be OK to add a Wiki page on the Code::Blocks Wiki?

Thanks
Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Anyone know of a minGW GCC Installation(Build from source) Tutorial?
« Reply #1 on: January 26, 2007, 11:23:58 pm »
I've built GCC 4.1.1 using MinGW and MSys, and out of the other C::B forum members I know Ceniza at least has also done so.

Basically, you need to install MinGW and then install MSys. I don't remember whether or not I had to install any additional tools from the MSys category, but I don't think I did. I actually did another build of GCC 4.1.1 just a week or so ago in order to build Ogre from source, and it pretty much worked the same way as it did my first time.

The GCC prerequisites page mentions quite a few tools you don't need to build GCC 4.0 or 4.1 series: in particular, GMP and MPFR are only necessary for 4.2 and later. All you should really need are a full install of MinGW (gcc, binutils, make), MSys, and the GCC sources. Since all I ever use GCC for is C and C++, those are the only two source packages I download and extract.

The first time I built GCC 4, I followed MinGW's GCC 3.4.5 build script as closely as possible. See this page for the details. Like any other piece of GNU software, it's at heart a matter of ./configure, make, make install. I always set DESTDIR to a temporary staging area for the make install step so that I can then swap different versions of GCC around as necessary.

Here was the process I followed for my most recent build of GCC 4.1.1:
(extract gcc-core-4.1.1.tar.gz and gcc-g++-4.1.1.tar.gz)
(create folder named "gcc-4.1.1-stage" next to gcc-4.1.1)
(open MSys)
Code
cd /I/Projects/GCCBuild/gcc-4.1.1-stage
../gcc-4.1.1/configure --with-gcc --with-gnu-ld --with-gnu-as --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++ --disable-win32-registry --enable-fully-dynamic-string
make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads -fno-omit-frame-pointer -O2" LDFLAGS=-s bootstrap 2>errlog.txt
At some point during the make process, make errors out with a message about an invalid pattern or some such. This is fixed by opening gcc-4.1.1-stage/gcc/Makefile and correcting the ORIGINAL_LD_FOR_TARGET definition. Then the same command is run again. Once the make process is finally successful:
Code
make DESTDIR=/I/Projects/GCCBuild/gcc-4.1.1-final install

At this point, gcc-4.1.1-final contains the subfolder "mingw", which contains the main GCC installation. I then copy over MinGW's prebuilt binutils, w32api, mingw32-make, and friends, and I'm ready to go.

Hope that helps!
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7680
    • My Best Post
Re: Anyone know of a minGW GCC Installation(Build from source) Tutorial?
« Reply #2 on: January 26, 2007, 11:32:56 pm »
TDragon: Thank you for the info.
Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Grom

  • Almost regular
  • **
  • Posts: 206
Re: Anyone know of a minGW GCC Installation(Build from source) Tutorial?
« Reply #3 on: January 27, 2007, 12:50:24 am »
Did you use some optimization keys for the gcc compiler?
Say processor and code optimization... Actually I was tired  waiting hen my code will be compiled. :x
gcc+winXP+suse.