Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th March 2006, 19:52   #1  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Compiling GCC for MinGW & Cross-Compiling with Linux

I've made this little guide to get a working MinGW gcc-4.0.3 up to gcc-4.1.2 (should work with binutils too)

i did have the latest build on my googlepage but it ran out of bandwidth, unless anybody canrecommend a freehost - its back to the previous way

try this (check http://www.mingw.org/download.shtml for updates)

MinGW-5.1.3-[candidate only base-files]

http://prdownloads.sf.net/mingw/MinG...3.exe?download

MSYS-1.0.10.exe

http://prdownloads.sf.net/mingw/MSYS...0.exe?download

if you need cvs
http://prdownloads.sf.net/mingw/msys...1.exe?download

and when installing if the connection drops, click retry (sf problem)

and i recommend to get latest runtime,w32api headers
http://sourceforge.net/project/showf...ease_id=158844
http://sourceforge.net/project/showf...ease_id=158847

and the new binutils that allows spaces in filenames
https://sourceforge.net/forum/forum.php?forum_id=661143

and if building hogs your system i recommend editing the msys.bat

change the:
line 62: start rxvt ... into start /LOW rxvt ... and
line 66: start sh ... into start /LOW sh ...
(more reliable for your system, you can do other while building)

get gcc-sources try here:
http://www.mirrorservice.org/sites/s...t.com/pub/gcc/

release directory or whatever


***** most of the pre-released/snapshots of gcc needs bison,flex and sometimes libiconv, libtool

bison into \mingw\ directory --
http://gnuwin32.sourceforge.net/down...on-bin-zip.php
http://gnuwin32.sourceforge.net/down...on-dep-zip.php

flex into \mingw\ directory --
http://gnuwin32.sourceforge.net/down...ex-bin-zip.php

libtool into \mingw\ directory --
http://gnuwin32.sourceforge.net/down...ol-bin-zip.php

libiconv into \mingw\
http://gnuwin32.sourceforge.net/down...nv-bin-zip.php
http://gnuwin32.sourceforge.net/down...nv-dep-zip.php

and maybe newer gnu-make (not needed but useful and sometimes buggy)
http://prdownloads.sourceforge.net/m...3.exe?download

installing the newer make delete/rename old msys\1.0\bin\make.exe and install the new make into \mingw\ and then
rename the new mingw32-make.exe into make.exe

make --version to check

or compile your own from http://ftp.gnu.org/gnu/make/

***

The directory that should contain system headers does not exist:
/usr/include

create an empty include folder in \msys\1.0\

***

make[2]: Leaving directory `/home/user/svn/gcc-4_1-branch/build/libcpp'
make[2]: Entering directory `/home/user/svn/gcc-4_1-branch/build/gcc'
Makefile:1280: *** target pattern contains no `%'. Stop.
make[2]: Leaving directory `/home/user/svn/gcc-4_1-branch/build/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/user/svn/gcc-4_1-branch/build'
make: *** [all] Error 2

check makefile = LD = ld
(not LD = ?:/mingw/bin/../lib/gcc/mingw32/???/../../../../mingw32/bin/ld.exe)
i think related to --with-gcc --with-gnu-ld --with-gnu-as

or delete ld.exe from \mingw\mingw32\bin or empty the folder that's what i did
(but i think the newer binutils fixes that anyway, will check later)

****

Step 1

cd yourgcc-src
mkdir build
cd build

Step 2
tip. before you install new gcc zip your \mingw\ directory ... you never know

Pass 1

append "&> output-results.txt" without quotes to echo to file (displayed text into a file)

after some experiments, i found symbolic links are broke, not sure on how to fix it

you can append: --with-dwarf2 -s (for silent output) to configure line
you can append &>result.txt to pipe any shell output to file


*** for gcc 4.1+ use bison,flex see notes on ld.exe

*** for gcc 4.2+ append --disable-werror

*** updated configure 2006.12.23 (remove --host=mingw32 --target=mingw32 to build for your system)

(remove '"CFLAGS=-O2" "LDFLAGS=-s" --enable-optimize' if debugging the compiler)


for i386
Quote:
../configure --enable-languages=c -v --enable-optimize --host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x
for i686
Quote:
../configure --enable-languages=c -v --enable-optimize --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x

Quote:
make "CFLAGS=-O2" "LDFLAGS=-s"
or
Quote:
make bootstrap "CFLAGS=-O2" "LDFLAGS=-s"
* if the bootstrap fails something is wrong with gcc compiler itself, means it can't rebuild itself with itself


(you can save it for later, if you re-install mingw just copy the folder back in)
Quote:
make DESTDIR=/home/gcc-build install
(the normal install)
Quote:
make install
Quote:
make html
(if you want the html - docs, there should be here yourgcc-src\libstdc++-v3\docs\html )

close and re-load ming

Step 3

Pass 2

empty your build directory

if you need g77 its not supported in gcc 4+, try gcc 3.4.4
but if want to build gfortran read further down

available languages are: c,c++,f95,java,objc,obj-c++,treelang

*** for gcc 4.2+ append --disable-werror


for i386
Quote:
../configure --enable-languages=c,c++ -v --enable-optimize --host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x
for i686
Quote:
../configure --enable-languages=c,c++ -v --enable-optimize --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x

Quote:
make "CFLAGS=-O2" "LDFLAGS=-s"
or
Quote:
make bootstrap "CFLAGS=-O2" "LDFLAGS=-s"
* if the bootstrap fails something is wrong with gcc compiler itself, means it can't rebuild itself with itself


(you can save it for later, if you re-install mingw just copy the folder back in)
Quote:
make DESTDIR=/home/gcc-build install
(the normal install)
Quote:
make install
close and re-load ming

Step 4

Pass 3 ( build gcc with gcc with profiled bootstrap to get a faster compiler)
this not necessary but you get a faster compiler

empty your build directory


for i386
Quote:
../configure --enable-languages=c,c++ -v --enable-optimize --host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x
for i686
Quote:
../configure --enable-languages=c,c++ -v --enable-optimize --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x

Quote:
make "CFLAGS=-O2" "LDFLAGS=-s"
or
Quote:
make bootstrap "CFLAGS=-O2" "LDFLAGS=-s"
* if the bootstrap fails something is wrong with gcc compiler itself, means it can't rebuild itself with itself


(you can save it for later, if you re-install mingw just copy the folder back in)
Quote:
make DESTDIR=/home/gcc-build install
(the normal install)
Quote:
make install
***

Fortran, GMP, MPFR

Building GMP

download gmp from
http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/

cd your gmp-src

Quote:
./configure --host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw
Quote:
make DESTDIR=/home/gcc-libs install
Quote:
make install
Building MPFR

download mpfr from
http://www.mpfr.org/mpfr-current/

cd your mpfr-src

Quote:
./configure --host=mingw32 --build=mingw32 --target=mingw32 --prefix=/mingw
Quote:
make DESTDIR=/home/gcc-libs install
Quote:
make install
Building Fortran (F95)

cd your gcc-src
mkdir build
cd build


Quote:
../configure --enable-languages=f95 -v --enable-optimize --prefix=/mingw --oldincludedir=/mingw/include --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x

Quote:
make "CFLAGS=-O2 " "LDFLAGS=-s"
or
Quote:
make bootstrap "CFLAGS=-O2" "LDFLAGS=-s"

(save for later installs)
Quote:
make DESTDIR=/home/f95-build install
Quote:
make install
**** more to add later

Compiling GCC for MinGW from Linux

update in progress...

see later posts

**** more to add later

thanks to those who helped, you know who you are

cheers
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC

Last edited by cc979; 3rd August 2009 at 04:00.
cc979 is offline   Reply With Quote
Old 6th March 2006, 15:03   #2  |  Link
Inventive Software
Turkey Machine
 
Join Date: Jan 2005
Location: Lowestoft, UK (but visit lots of places with bribes [beer])
Posts: 1,953
Maybe adding Fortran (g77)? I'm 95% certain that'll compile with no problems. GCC/MinGW usually stumbles with ObjectiveC and/or Java.

Why do people insist on having GCC 4 working with MinGW? What was wrong with GCC 3.4.5? I've been using that with no problems at all.
__________________
On Discworld it is clearly recognized that million-to-one chances happen 9 times out of 10. If the hero did not overcome huge odds, what would be the point? Terry Pratchett - The Science Of Discworld
Inventive Software is offline   Reply With Quote
Old 6th March 2006, 15:30   #3  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by Inventive Software
Maybe adding Fortran (g77)? I'm 95% certain that'll compile with no problems. GCC/MinGW usually stumbles with ObjectiveC and/or Java.

Why do people insist on having GCC 4 working with MinGW? What was wrong with GCC 3.4.5? I've been using that with no problems at all.
can do, i myself - not used fortran for ages

people must like new toys to play with - optimizing stuff gcc 4.1 sounds interesting
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 8th March 2006, 17:52   #4  |  Link
leowai
Registered User
 
Join Date: May 2005
Posts: 184
@cc979, thanks for the guide.

And I've a suggestion here. I see the commands to MinGW are mixed with your comments. It will be much clearer if you put the commands in code box like this:
Code:
../configure --enable-languages=c --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization --enable-libstdcxx-debug
Or using "quote":
Quote:
../configure --enable-languages=c --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization --enable-libstdcxx-debug
leowai is offline   Reply With Quote
Old 9th March 2006, 12:59   #5  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by leowai
@cc979, thanks for the guide.

And I've a suggestion here. I see the commands to MinGW are mixed with your comments. It will be much clearer if you put the commands in code box like this:
Code:
../configure --enable-languages=c --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization --enable-libstdcxx-debug
Or using "quote":
can do
cheers
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 23rd March 2006, 22:06   #6  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by hpn
@cc979
Nice guide for people who already know how to do it, but the whole compilation will never be doable for the average Joe (unless you're a clairvoyant), due to lots of path typos (like what the h*** is /sys/1.0/ directory ), missing or messy steps and ambiguities. A working gcc compilation guide should have about 30 detailed steps, not 4 or 5.
after installing MSYS you get a /sys/1.0/ directory or where you have installed

in '30 steps' have tried ?

path typo ? tell me where
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 24th March 2006, 16:06   #7  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by hpn
/sys/1.0/ should be /msys/1.0/ ..

I mean about 30 steps like this otherwise it's not a step by step guide, but a quick reference (kind of reminder) for people who already know how to compile it. I'll try to fix the gcc guide (for gcc-core-4.2.x) and post it later here.
cheers
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 24th November 2006, 05:38   #8  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
pre-release builds gcc-4.2-20061114, gcc-4.3-20061118

i've built build gcc-4.2-20061114, gcc-4.3-20061118

if anyone wants them, not tried build ffdshow with them yet

check out, about the
Quote:
warning: format '%I64d' expects type
'int', but argument 3 has type 'gcov_type'
http://www.nabble.com/-Bug-bootstrap....html#a2025034

gmp-4.2,mpfr-2.2.0 (not sure the libs are needed for the gcc-dists) and updated bison,flex,libtool,libiconv was used to build the latest snapshots of gcc 4.2 & 4.3

read the first page for more details

the files
http://www.mytempdir.com/1079929
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 24th November 2006, 07:56   #9  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,556
Yes! This is awesome, mainly because I've been itching to use OpenMP in ffmpeg and gcc 4.3 finally implements it. I'll probably have to run some experiments with it first to see how functional it is.
foxyshadis is offline   Reply With Quote
Old 24th November 2006, 14:09   #10  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by foxyshadis View Post
Yes! This is awesome, mainly because I've been itching to use OpenMP in ffmpeg and gcc 4.3 finally implements it. I'll probably have to run some experiments with it first to see how functional it is.
your welcome, let me know how it goes for you - i had problems with the baseclasses compiling ffdshow myself, help - if you can do it

cheers
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 25th November 2006, 01:32   #11  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
with gcc-4.3 ffdshow fails on baseclasses

see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20652

and some else ran into compiling other sources
http://www.nabble.com/gcc-4.1%3A-Wei....html#a2150693
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC

Last edited by cc979; 25th November 2006 at 01:36.
cc979 is offline   Reply With Quote
Old 25th November 2006, 01:57   #12  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,556
I was only going to use it for lavc/mplayer, so that shouldn't affect me to much at the moment. It'll be interesting trying to test for any bugs introduced though.

btw, was this cross-compiled from linux, or compiled off the existing 4.0/4.1 gcc for win32?
foxyshadis is offline   Reply With Quote
Old 25th November 2006, 17:29   #13  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by foxyshadis View Post
I was only going to use it for lavc/mplayer, so that shouldn't affect me to much at the moment. It'll be interesting trying to test for any bugs introduced though.

btw, was this cross-compiled from linux, or compiled off the existing 4.0/4.1 gcc for win32?
i used win32 mingw gcc 4.0.3 if remember as it was after few failed attempts, till i realised what it needed
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 28th November 2006, 21:01   #14  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
build 4.1.2 20061127 (prerelease) - patched
can build ffdshow needs testing

http://www.mytempdir.com/1088799
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 19th December 2006, 13:01   #15  |  Link
clsid
*****
 
Join Date: Feb 2005
Posts: 5,640
Somehow all the executables in your builds are much larger than 'official' mingw32 builds. I once made a build myself and had the same problem.

Perhaps the executables contain debugging or other unneeded code? Hopefully you can figure out what is wrong and 'fix' it. As it might affect the performance of the compilers too.
__________________
MPC-HC 2.1.7.2
clsid is offline   Reply With Quote
Old 19th December 2006, 21:55   #16  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
Quote:
Originally Posted by clsid View Post
Somehow all the executables in your builds are much larger than 'official' mingw32 builds. I once made a build myself and had the same problem.

Perhaps the executables contain debugging or other unneeded code? Hopefully you can figure out what is wrong and 'fix' it. As it might affect the performance of the compilers too.
i had it include GMP, MPFR libs maybe thats affecting it, i look into it
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 23rd December 2006, 12:05   #17  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
gcc-build 4.1.2 20061222 (prerelease)

new build of gcc-4.1.2

http://www.mytempdir.com/1130278

@clsid used the strip option this time, are indeed smaller
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 23rd December 2006, 13:45   #18  |  Link
clsid
*****
 
Join Date: Feb 2005
Posts: 5,640
Thanks.
__________________
MPC-HC 2.1.7.2
clsid is offline   Reply With Quote
Old 2nd February 2007, 21:04   #19  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
gcc-build-4.1.2-121479

just built gcc-build-4.1.2-121479 if anyone wants

http://www.mytempdir.com/1199083

let me know, if anything wrong
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Old 7th February 2007, 14:32   #20  |  Link
cc979
Curious BetaTester
 
Join Date: Oct 2005
Posts: 430
https://sourceforge.net/project/show...?group_id=2435

The 2.17.50-200700129-1 snapshot incorporates modifications to official
binutils CVS since last update. In addition it patches windres to allow
use of spaces in filenames,
__________________
Asrock N68-S AMD Athlon(tm) II X4 620 Processor (2.6GHz) - Crucial 2GB PC6400 800MHz DDR2 - Nvidia 9600GT

Tools: ProcessExplorer & ProcessMonitor - BatchCompressor

Guide: MinGW Compiling GCC
cc979 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.