Problems with building a mingw cross-compiler

Pieter Thysebaert pieter.thysebaert@intec.rug.ac.be
Wed Jan 15 09:26:00 GMT 2003


On Wednesday 15 January 2003 01:27, Paul Millar wrote:
> Hi,
>
> I'm trying to compile a cross-compiler that will generate Windows binaries
> from a Linux host.  I'm hitting two (probably related) problems.
>

>From your (entire) post, I assume you want mingw32 target on a linux host & 
build.
I've done that twice in a single week, although that's been a while now ;-).

I used gcc 3.2.1, binutils 2.13.1 (from some GNU mirror)
w32API 2.1, mingw runtime source 2.2 from www.mingw.org

I believe I did this:

export PREFIX=/usr/local/cross 
tar xvfz binutils-2.13.1.tar.gz
mkdir build-binutils
cd build-binutils
../binutils-2.13.1/configure --host=i686-pc-linux-gnu
   --build=i686-pc-linux-gnu --target=i686-pc-mingw32 
   --prefix=$PREFIX

make
make install

cd ..
export PATH=$PREFIX/bin:$PATH
tar xvfz mingw-whatever.tar.gz

cp -r ming-whatever/include $PREFIX/i686-pc-mingw32/include
(you want standard C headers for mingw in $PREFIX/target/include)

tar xvfz gcc-3.2.1.tar.gz
mkdir build-gcc
cd build-gcc
../gcc-3.2.1/configure --prefix=$PREFIX --host=i686-pc-linux-gnu 
--build=i686-pc-linux-gnu --target=i686-pc-mingw32 --without-headers 
--with-newlib --disable-threads --enable-languages=c

make 
make install

cd..
tar xvfz w32api-2.1.tar.gz
mkdir build-w32api
cd build-w32api
../w32api-2.1/configure --prefix=$PREFIX/i686-pc-mingw32 
--build=i686-pc-linux-gnu --host=i686-pc-mingw32

make 
make install
(you should now have windows header files in prefix/target/include and import 
libs in prefix/target/lib)

cd ..
mkdir build-mingw
cd build-mingw
../mingw-whatever/configure --build=i686-pc-linux-gnu --host=i686-pc-mingw32 
--prefix=$PREFIX/i686-pc-mingw32

I had to tweak the mingw Makefiles here (3 in total) because the CFLAGS did 
not include a dirtectory containing the required windows header files; adding 
-I$(PREFIX)/i686-pc-mingw32/include to INCLUDES did the trick

make
make install

cd ../build-gcc
rm -rf *
../gcc-3.2.1/configure --prefix=$PREFIX --host=i686-pc-linux-gnu 
--build=i686-pc-linux-gnu --target=i686-pc-mingw32 --enable-threads 
--enable-languages=c,c++ --disable-long-long

make
make install

I had to specify --disable-long-long because I get undefined symbols 
(regarding string-to-long-long conversion) in the resulting libstdc++.




Pieter




More information about the Gcc-help mailing list