Compiling PE executables using linux hosted gcc

Brian Dessent brian@dessent.net
Sun Apr 13 17:45:00 GMT 2008


Jay wrote:

> Hi! I'm developing a cross-platform framework and now it's time to port
> it to Win32. I found that i can compile an executable for a certain
> platform specifying -b command-line option however what i found further
> just confused me so i'm here asking you this dumb question: how to
> compile a pe executable using a linux hosted gcc? I run ubuntu 7.10 and
> gcc 4.2.1. Many thanks in advance.

You need to build a cross toolchain (cross compiler, cross linker, cross
assembler.)  Note that gcc is just a compiler, it does not include the
linker or assembler which are part of binutils.

Just because Linux and Win32 both run on the same ia32 hardware does not
mean you can use the same tools, they are significantly different
targets/platforms (e.g. the PE assembler directives are not the same as
the ELF assembler, the linker is totally different, etc.)

The MinGW site has some scripts that will build such a set of cross
tools which is a good place to start since there can be a lot of minor
details to get right.  Also, those scripts will use gcc sources with
MinGW patches integrated, which fix a number of things that are broken
or unsupported in FSF gcc.  Therefore if you have trouble with the
scripts, post on the MinGW list.

Brian



More information about the Gcc-help mailing list