PDA

View Full Version : Generate a Windows executable under Linux with gcc/g++



caduardo21
07-10-2005, 09:16 AM
I'm sure this question has already been asked before but I couldn't find anything on it so...

Can someone tell me if it's possible and how to do it? Thanks.

Salem
07-10-2005, 10:03 AM
Quickest way would be to run dev-c++ within WINE.

With some effort/skill, it should be possible to install gcc hosted on linux and producing win32 executables (probably start by looking at what mingw do).

What you need to be looking for are called cross-compilers, which run on machine 'a' and produce programs for machine 'b'. It's usually the preserve of the embedded programming community, since most desktop types just compile and execute on the same machine.

Muphin
07-10-2005, 04:26 PM
You need these packages

xmingw-binutils Tools necessary to build Win32 programs
xmingw-gcc The GNU Compiler Collection - i386-mingw32msvc-gcc only
xmingw-runtime Free Win32 runtime and import library definitions
xmingw-w32api Free headers and libraries for the Win32 API

I dunno where to find them though :cool:

Then in a console type this (make sure you are logged in as the same user that will do the compiling)

alias g++w32="/opt/xmingw/bin/i386-mingw32msvc-g++"

Now you are ready to compile your cpp for windows:

i386-mingw32msvc-g++ ./<cppname>.cpp -o <nameoffile>.exe

dwks
07-14-2005, 05:39 PM
You might be able to ask someone with Windows to compile your program for you.

Jaqui
07-15-2005, 05:05 AM
which tool did you use to create the code?
most of the linux tools are linux specific.

but qt is cross platform.
if you can pull it into qt designer then save it, with project options including windows support, gcc's make will be able to use the win32 targets to cross compile.

much easier than installing cygwin / mingw, or finding someone with windows AND a compatable compiler.
( most windows compilers are not compatable wiith gcc. )

major_small
07-15-2005, 05:18 AM
much easier than installing cygwin / mingw, or finding someone with windows AND a compatable compiler.
( most windows compilers are not compatable wiith gcc. )cygwin is for making linux stuff useable in windows... and Dev-C++ uses GCC... or you could just have them use GCC... (there's a MingW port for windows)

they don't need a compiler compatible with GCC anyway if your code is standard... if you used all standard coding you should just be able to pass it on to any windows user (there's a few out there... just ask around) with any (c/c++) compiler and they should be able to give you the binary.

Quickest way would be to run dev-c++ within WINE.

what about running the MingW port of GCC within WINE? would that work?

Jaqui
07-15-2005, 05:52 AM
it might, but since qt designer is available with most distros, and has the cross platform support, it's probably the easiest for enabling the cross compiling that gcc and g++ can do.

if it's not installed, installing a linux app and associated libs is far simpler than tweaking wine to run an app that is designed to use gcc and g++ under mingw in windows.

the hardest effective way would be to manually edit the makefile to add win32 targets to it.
then, at the bash prompt, you would only have to enter the make -windows target name