LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Closed Thread
  Search this Thread
Old 02-23-2008, 12:15 PM   #1
bugscripts
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
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.
 
Old 02-23-2008, 01:08 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Sounds like you need the Mono Project: http://www.mono-project.com/Main_Page.
 
Old 02-23-2008, 04:49 PM   #3
JWPurple
Member
 
Registered: Feb 2008
Posts: 67

Rep: Reputation: 17
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.
 
Old 02-23-2008, 05:08 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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
 
Old 02-24-2008, 06:41 AM   #5
bugscripts
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 02-24-2008, 07:06 PM   #6
JWPurple
Member
 
Registered: Feb 2008
Posts: 67

Rep: Reputation: 17
Quote:
Originally Posted by bugscripts View Post
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.

Last edited by JWPurple; 02-24-2008 at 07:07 PM.
 
Old 02-24-2008, 08:54 PM   #7
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
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

Last edited by ComputerGreek; 02-27-2008 at 06:47 PM.
 
Old 02-25-2008, 05:29 PM   #8
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
I will go through the compilation when I get time and check the commands.
 
Old 02-26-2008, 05:26 PM   #9
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Note that i missed the line:

ln -s w32api-3.11 w32api

I just added it.
 
Old 02-27-2008, 06:46 PM   #10
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Deleted a little misleading info.
 
Old 02-28-2008, 04:21 PM   #11
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Don't forget to change --build=i686-pc-linux-gnu to whatever type your machine is.
 
Old 02-29-2008, 04:41 PM   #12
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Anyone tried the compilation?
 
Old 03-03-2008, 08:44 AM   #13
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
BTW you have to clean up between the builds.
 
Old 03-04-2008, 06:32 AM   #14
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Tried it. It works.
 
Old 03-04-2008, 06:00 PM   #15
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Quote:
Originally Posted by ComputerGreek View Post
Tried it. It works.
Actually, what I mean is that everything compiled.
 
  


Closed Thread

Tags
binutils, compiler



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why is compiling source programs under linux such a headache? guy24x Linux - Software 21 07-28-2005 06:04 AM
Windows programs on linux ahimsel08 Linux - Software 20 06-20-2004 04:35 PM
linux and windows programs robster Linux - General 3 02-16-2004 07:07 PM
Can Windows use Linux Programs? BlackEcho Linux - General 5 11-17-2003 12:22 AM
windows programs on linux SchoolITguy Linux - Software 2 04-03-2003 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration