public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems with building a mingw cross-compiler
@ 2003-01-15  0:27 Paul Millar
  2003-01-15  9:26 ` Pieter Thysebaert
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Millar @ 2003-01-15  0:27 UTC (permalink / raw)
  To: gcc-help

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.

The first problem is that gcc/crtstuff.c includes
gcc/config/i386/cygming.h, which tries to #include <stdio.h>, but fails.  
This leads to FILE not being defined, causing prototypes to fail:

  [path]/build/gcc/xgcc -B[path]/build/gcc/ -nostdinc 
       -B[path]/build/i386-mingw32/newlib/ -isystem 
       [path]/build/i386-mingw32/newlib/targ-include 
       -isystem [path]/newlib/libc/include -B/usr/local/i386-mingw32/bin/ 
       -B/usr/local/i386-mingw32/lib/ -isystem 
       /usr/local/i386-mingw32/include -O2 -DIN_GCC -DCROSS_COMPILE   -W 
       -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes 
       -isystem ./include  -I. -I. -I../../gcc -I../../gcc/.
       -I../../gcc/config -I../../gcc/../include  -g0 
       -finhibit-size-directive -fno-inline-functions -fno-exceptions  \
       -Dinhibit_libc -c ../../gcc/crtstuff.c -DCRT_BEGIN \
       -o crtbegin.o
  In file included from tconfig.h:16,
       from ../../gcc/crtstuff.c:61:
       ../../gcc/config/i386/cygming.h:31:19: stdio.h: No such file or 
       directory
  In file included from tconfig.h:16,
       from ../../gcc/crtstuff.c:61:
       ../../gcc/config/i386/cygming.h:364: parse error before '*' token
       ../../gcc/config/i386/cygming.h:364: warning: function declaration 
       isn't a prototype
       ../../gcc/config/i386/cygming.h:366: parse error before '*' token
       ../../gcc/config/i386/cygming.h:366: warning: function 
       declaration isn't a prototype
  make[1]: *** [crtbegin.o] Error 1
  make[1]: Leaving directory 
        `/usr/src/redhat/BUILD/gcc-3..2.1-20021201-2/build/gcc'

Changing gcc/config/i386/cygming.h via:

--- cygming.h-old	Tue Jan 14 12:56:06 2003
+++ cygming.h	Tue Jan 14 12:56:17 2003
@@ -28,7 +28,7 @@
 
 #define TARGET_EXECUTABLE_SUFFIX ".exe"
 
-#include <stdio.h>
+#include "system.h"
 #include "i386/gas.h"
 #include "dbxcoff.h"
 
allows the compilation to continue.

However, later the compilation fails again.  This time, gcc complains
about missing header files, and that malloc is poisoned (whatever *that*
means).

  [path]/build/gcc/xgcc -B[path]/build/gcc/ -nostdinc 
  -B[path]/build/i386-mingw32/newlib/ -isystem 
  [path]/build/i386-mingw32/newlib/targ-include 
  -isystem [path]/newlib/libc/include 
  -B/usr/local/i386-mingw32/bin/ -B/usr/local/i386-mingw32/lib/ 
  -isystem /usr/local/i386-mingw32/include -O2 -DIN_GCC -DCROSS_COMPILE   
  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes 
  -isystem ./include  -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/config 
  -I../../gcc/../include  -g0 -finhibit-size-directive 
  -fno-inline-functions -fno-exceptions  \
  -Dinhibit_libc -c ../../gcc/crtstuff.c -DCRT_BEGIN \
  -o crtbegin.o
  In file included from ../../gcc/config/i386/cygming.h:31,
                   from tconfig.h:16,
                   from ../../gcc/crtstuff.c:61:
[...]
  ../../gcc/system.h:200:23: sys/time.h: No such file or directory
  ../../gcc/system.h:201:19: time.h: No such file or directory
  ../../gcc/system.h:213:20: fcntl.h: No such file or directory
  ../../gcc/system.h:251:22: sys/wait.h: No such file or directory
  ../../gcc/system.h:312:20: malloc.h: No such file or directory
  ../../gcc/system.h:381:23: sys/stat.h: No such file or directory
  In file included from tconfig.h:16,
                 from ../../gcc/crtstuff.c:61:
  ../../gcc/config/i386/cygming.h:364: parse error before '*' token
  ../../gcc/config/i386/cygming.h:364: warning: function declaration isn't 
      a prototype
  ../../gcc/config/i386/cygming.h:366: parse error before '*' token
  ../../gcc/config/i386/cygming.h:366: warning: function declaration isn't 
      a prototype
  In file included from ../../gcc/crtstuff.c:62:
  ../../gcc/tsystem.h:41:9: attempt to use poisoned "malloc"
  make[1]: *** [crtbegin.o] Error 1

I'm using gcc-3.2.1 (from http://www.trilithium.com/software/misc/) to
compile gcc-3.2.1 for the target i386-mingw32.  I've tried various
configurations (and variations on the target), none have worked.  For the
above compilation, I used:

  ../configure --target=i386-mingw32 --prefix=/usr/local 
  --with-local-prefix=/usr/local/i386-mingw32 --with-newlib 
  --enable-threads --disable-nls --enable-languages=c,c++,f77,objc 
  --disable-win32-registry --disable-shared --enable-sjlj-exceptions


This looks like some kind of path problem (cause by configure?). If so,
I'm not sure what's gone wrong.  The directory /usr/local/i386-mingw32
doesn't exist yet.

I've placed the config.cache file at:
   http://www.astro.gla.ac.uk/users/paulm/config.cache
in case its of any use.

I've also tried gcc-3.2 as well, with (more or less) identical results.

Any ideas?

Cheers,

Paul.

PS.
[path] above is /usr/src/redhat/BUILD/gcc-3..2.1-20021201-2 btw.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Particle Physics (Theory & Experimental) Groups                Dr Paul Millar 
Department of Physics and Astronomy                     paulm@astro.gla.ac.uk
University of Glasgow                                 paulm@physics.gla.ac.uk
Glasgow, G12 8QQ, Scotland             http://www.astro.gla.ac.uk/users/paulm 
+44 (0)141 330 4717        A54C A9FC 6A77 1664 2E4E  90E3 FFD2 704B BF0F 03E9
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with building a mingw cross-compiler
  2003-01-15  0:27 Problems with building a mingw cross-compiler Paul Millar
@ 2003-01-15  9:26 ` Pieter Thysebaert
  2003-01-20 11:10   ` Paul Millar
  0 siblings, 1 reply; 3+ messages in thread
From: Pieter Thysebaert @ 2003-01-15  9:26 UTC (permalink / raw)
  To: Paul Millar, gcc-help

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with building a mingw cross-compiler
  2003-01-15  9:26 ` Pieter Thysebaert
@ 2003-01-20 11:10   ` Paul Millar
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Millar @ 2003-01-20 11:10 UTC (permalink / raw)
  To: Pieter Thysebaert; +Cc: gcc-help

Hi Pieter,

Thanks for the information.  It was the breakthrough that helped me get on
top of this problem.  Turns out there's a circular dependency:  mingw-gcc
depends on the "w32api" and "mingw-runtime" packages (specifically, the
include files)  whilst those packages require mingw-gcc to have already
been built before they compile and install :^(

There was another wrinkle about the build-order inside the mingw-runtime
package: the root build required libmingwex.a to exist (built inside the
mingwex directory), but it doesn't start the build automatically.

I've put all the information together into a script that should do all the 
dirty business of building mingw.  Its available from 
  http://www.astro.gla.ac.uk/users/paulm/Scripts/build-mingw-cross.sh

I'm currently having a problem with mingw includes.  I suspect its a
problem with the code, but I'd be grateful if you could try the script out
and let me know if it works for you.

Thanks again for you help

Paul.

On Wed, 15 Jan 2003, Pieter Thysebaert wrote:
> 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
> 
> 
> 
> 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Particle Physics (Theory & Experimental) Groups                Dr Paul Millar 
Department of Physics and Astronomy                     paulm@astro.gla.ac.uk
University of Glasgow                                 paulm@physics.gla.ac.uk
Glasgow, G12 8QQ, Scotland             http://www.astro.gla.ac.uk/users/paulm 
+44 (0)141 330 4717        A54C A9FC 6A77 1664 2E4E  90E3 FFD2 704B BF0F 03E9
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-20 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-15  0:27 Problems with building a mingw cross-compiler Paul Millar
2003-01-15  9:26 ` Pieter Thysebaert
2003-01-20 11:10   ` Paul Millar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).