LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Compiling programs for Windows on Linux (https://www.linuxquestions.org/questions/linux-software-2/compiling-programs-for-windows-on-linux-623329/)

bugscripts 02-23-2008 12:15 PM

Compiling programs for Windows on Linux
 
I have a Mac and a Linux PC, and I want to compile a game I made in C++ so it will work on Windows. I tried running MinGW with WINE, but got a lot of strange errors when compiling my program. With some Google searching, I found some info on cross compiling with GCC, but it sounded extremely complicated. What is the easiest way to do this? I have only been using Linux (Ubuntu) since December, so I still don't know a whole lot about it.

Thanks.

bigrigdriver 02-23-2008 01:08 PM

Sounds like you need the Mono Project: http://www.mono-project.com/Main_Page.

JWPurple 02-23-2008 04:49 PM

Your big problem is that the app will need to make major use of windows gui dll's that you don't have on the other OS's. The API for those is proprietary (recently opened, but not available yet?).

Your best bet for long-term cross platform gui development is to use a cross-platform gui framework. I think Gtk is working on this for windows. There is a commercial one called XVT.

You might have major issues if your game uses sound and complex video like 3d acceleration, since these require OS-specific drivers.

jailbait 02-23-2008 05:08 PM

JWPurple's idea of using Gtk+ on Windows is a good way to port your game to Windows. Another way to do the same thing is to use Qt.

http://freshmeat.net/projects/qt/

----------------------
Steve Stites

bugscripts 02-24-2008 06:41 AM

Thanks for the replies. I am actually using the Allegro library. Would I still have to use windows GUI? On the Mac I didn't need to use any OS specific libraries.

JWPurple 02-24-2008 07:06 PM

Quote:

Originally Posted by bugscripts (Post 3068055)
I am actually using the Allegro library. Would I still have to use windows GUI? On the Mac I didn't need to use any OS specific libraries.

From the Allegro introduction, what you need for windows compiling is on of these: Windows (MSVC, MinGW, Cygwin, Borland). I would interpret that to mean you need to use one of these development environments on a windows machine, using the Allegro libraries. I don't think Allegro is a cross-compiler from linux->windows. It probably worked on the Mac because of the OS X platform that provides linux-compatible libraries already. Windows is not likely to do that for the forseeable future. :)

ComputerGreek 02-24-2008 08:54 PM

COMPILING THE mingw32 CROSS COMPILERS.

This is only a guide. It is real rough. You may need to fill in some of the potholes that are deliberately dug in your path by "Linux people." However, it should point you in the right direction.

This, plus some fancy footwork, worked for gcc-4.1.1

Download:

ftp://gcc.gnu.org/pub/binutils/relea...s-2.18.tar.bz2
ftp://gcc.gnu.org/pub/binutils/releases/md5.sum

ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/g...-4.2.3.tar.bz2
ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.3/md5.sum

http://downloads.sourceforge.net/min....11-src.tar.gz
http://downloads.sourceforge.net/min....14-src.tar.gz

Get the include files to the right place:

tar zxf w32api-3.11.tar.gz
tar zxf mingw-runtime-3.14.tar.gz

cp -r mingw-runtime-3.14/include/* /usr/local/mingw32/include
cp -r w32api-3.11/include/* /usr/local/mingw32/include

Build binutils-2.18 with:

./configure --target=mingw32 --program-prefix=mingw32
make
make install

Now build gcc:

for a in *4.2.3*.tar.bz2; do tar xf $a; done

They all open into the directory gcc-4.2.3

Create the compiler to build the libraries

./configure --target=mingw32 --with-headers=/usr/local/mingw32/include --enable-languages=c
make
make install

cd w32api-3.11
./configure --target=mingw32 --host=mingw32 --build=i686-pc-linux-gnu

ln -s w32api-3.11 w32api

cd mingw-runtime-3.14
./configure --target=mingw32 --host=mingw32 --build=i686-pc-linux-gnu

Create the mingw32 C & C++ COMPILERS

./configure --target=mingw32 --with-headers=/usr/local/mingw32/include --enable-languages=c,c++ --disable-libssp --enable-sjlj-exceptions
make
make install

ComputerGreek 02-25-2008 05:29 PM

I will go through the compilation when I get time and check the commands.

ComputerGreek 02-26-2008 05:26 PM

Note that i missed the line:

ln -s w32api-3.11 w32api

I just added it.

ComputerGreek 02-27-2008 06:46 PM

Deleted a little misleading info.

ComputerGreek 02-28-2008 04:21 PM

Don't forget to change --build=i686-pc-linux-gnu to whatever type your machine is.

ComputerGreek 02-29-2008 04:41 PM

Anyone tried the compilation?

ComputerGreek 03-03-2008 08:44 AM

BTW you have to clean up between the builds.

ComputerGreek 03-04-2008 06:32 AM

Tried it. It works.

ComputerGreek 03-04-2008 06:00 PM

Quote:

Originally Posted by ComputerGreek (Post 3077592)
Tried it. It works.

Actually, what I mean is that everything compiled.


All times are GMT -5. The time now is 09:35 AM.