Skip to contentSkip to conversation

Cross-compiling for Windows under Linux

DISCUSSION Shriramana Sharma 3 participants 5 messages Feb 18, 2006 – Feb 19, 2006

lore
Share & tools
lore
#0 lore raw

I am running SUSE Linux 10.0 and I would like to compile my programs for 32-bit Windows without booting to Windows.

If I boot to Windows, I can use gcc and make that come with Cygwin or MinGW, but I would like to avoid the hassle of booting to Windows at all.

Is there a way I can do this?

Thanks in advance.

Signature · 3 lines
Tux #395953 resides at http://samvit.org
playing with KDE 3.51 on SUSE Linux 10.0
$ date [] CCE +2006-02-18 W07-6 UTC+0530
#1 lore raw
Quoted 7 lines · Shriramana Sharma

I am running SUSE Linux 10.0 and I would like to compile my programs for 32-bit Windows without booting to Windows.

If I boot to Windows, I can use gcc and make that come with Cygwin or MinGW, but I would like to avoid the hassle of booting to Windows at all.

Is there a way I can do this?

Yes; for details, see:

http://vmlinux.org/crash/mirror/www.objsw.com/CrossGCC/

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw

Saturday, 18 February 2006 16:03 samaye tvayaa likhitam:

Quoted 1 line

http://vmlinux.org/crash/mirror/www.objsw.com/CrossGCC/

It's far above my head. Can anyone please explain what they are doing? Are they suggesting GCC can be used as I have it in my system (4.02 BTW) to create Windows binaries? There is some mention of a patch. Am I to build gcc myself from sources after applying the patch?

Thanks.

Signature · 3 lines
Tux #395953 resides at http://samvit.org
playing with KDE 3.51 on SUSE Linux 10.0
$ date [] CCE +2006-02-18 W07-6 UTC+0530
#3 lore raw
Quoted 3 lines · Shriramana Sharma
Quoted 1 line

http://vmlinux.org/crash/mirror/www.objsw.com/CrossGCC/

It's far above my head. Can anyone please explain what they are doing?

The FAQ explains how to compile versions of binutils and gcc which run on Linux but which generate binaries for other platforms (e.g. Windows).

The GNU tools (gcc, as (the assembler), ld (the linker) etc) can generate code for a wide variety of platforms, including Linux and Windows. They are written in C, and can be compiled to run on a wide variety of platforms. The platform on which the compiler/linker/etc runs doesn't have anything to do with the platform for which it generates binaries.

When you run the binutils/gcc/etc configure script, you use the --target option to tell it which platform you want it to generate code for (if you don't use this switch, it assumes that you want it to generate code for the platform on which the compiler runs).

E.g. if you want a compiler which generates Windows binaries, you would use --target=i686-pc-mingw32 (this worked the last time I built cross-gcc; check the installation instructions supplied with gcc for an up-to-date list of target names).

Quoted 2 lines

Are they suggesting GCC can be used as I have it in my system (4.02 BTW) to create Windows binaries?

The normal gcc and binutils packages from your OS vendor won't be able to generate Windows binaries. You need versions which were built to generate Windows (rather than Linux) binaries.

You might be able to get pre-compiled cross-gcc/binutils binaries for your system, otherwise you will need to build them from source.

Quoted 2 lines

There is some mention of a patch. Am I to build gcc myself from sources after applying the patch?

You shouldn't need any patches. The one mentioned in section 3 of the FAQ is specific to MS-DOS. You don't need it to generate Windows binaries.

Signature · 1 line
Glynn Clements <[email protected]>
#4 lore raw
In reply to Shriramana Sharma

Hello,

Shriramana Sharma napsal(a):

Quoted 5 lines

I am running SUSE Linux 10.0 and I would like to compile my programs for 32-bit Windows without booting to Windows.

If I boot to Windows, I can use gcc and make that come with Cygwin or MinGW, but I would like to avoid the hassle of booting to Windows at all.

Is there a way I can do this?

Look at these:
http://www.mingw.org/MinGWiki/index.php/build%20a%20Win32%20x-compiler%20for%20Linux
http://www.mingw.org/MinGWiki/index.php/BuildMingwCross

Signature · 8 lines
.---------    Tomáš Janoušek   a.k.a. Liskni_si    ---------.
: NOMI team, developer, http://tomi.nomi.cz/   [email protected] :
' JID:[email protected], ICQ#161807083, tel:+420608876277 '

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html