(Relatively) easy way to compile XCode projects in MinGW on Windows?

Member
Posts: 64
Joined: 2005.06
Post: #1
A while back, I decided to start looking into cross-platform compatibility, namely MacOS X (of course) and Windows. I accepted the fact that I would all but have to abandon Cocoa* save for platform-specific code, but I love my Obj-C and won't give it up, so I just installed and got MinGW working on my new Windows box (even managed to compile a quick windows shell program).

The problem is, gcc is entirely command-line, so compiling a large project would become a practice in frustration. Not to mention that debugging is quite frustrating when its limited to printing out data on the command-line.

So my question becomes, is there any program or method capable of easily converting an XCode project into something that gcc can easily compile? That would make it much easier for me to create the program in Xcode and simply use gcc as a Windows compiler.

Or, if anyone knows how to successfully integrate MinGW and Xcode, I'm all ears, as all the projects I've found that attempt to do just that, don't seem to work for me. Either that or they're going over my head.

* I already looked into Cocotron, but after busting my butt on trying to make it and other systems that integrate MinGW with XCode work, I've given up on them. None of them even begin to work.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #2
Dev-C++ is a reasonably nice IDE that wraps MinGW. It'll let you set up a project file that keeps track of your source files and gcc options. Alternately, MinGW comes with make, so you could set up a Makefile to build your code. If you used a Makefile on the Mac too, you might even be able to share some of the configuration between the two.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
As ThemsAllTook says, write a (Makefile|SConstruct|CMakefile|Rakefile|...) to build your project, and use it on all the platforms. On the Mac, you can create an Xcode project which builds via your portable build system, if you still want Xcode around. You lose source indexing unfortunately, but most other things work.

Re: Cocoa, AppKit certainly isn't portable, but Foundation basically seems to be (though stay away from ObjC2 features still). I've successfully used gnustep-base to replace Foundation on Linux, with only a couple of minor changes to my code. Just be careful to distinguish between Foundation-using portable code, and AppKit-using nonportable code, and keep AppKit out of places it shouldn't be.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #4
In addition to OSC's options, check out jam! Seriously, it's a flexible alternative to death by makefiles.

Also, check out Cocotron, NOT Cocoatron. I haven't tried it, but I've heard some good stuff.

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Cocotron runtime not thread-safe -> FAIL.

gnustep-base.
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #6
Here's an update:

I've been looking back into trying to install MinGW on MacOS X since Windows command-line doesn't even support spaces in folder-names among other issues. The problem I keep encountering is that all the different methods I've found of installing MinGW have either just plain not worked, or involve gcc_select, wget and a number of other command-line tools that Apple decided to apparently drop in Leopard. Even reinstalling them has led to more headaches, such as gcc_select, which would work if it was able to find gcc 3.3 or 4.0 on my computer (which XCode says it installed but isn't actually installed anywhere according to a file search).

If anyone has a step-by-step method of installing MinGW on MacOS X (preferably allowing XCode to cross-compile) that still works in Leopard, I would love to hear it.
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #7
I can't help with MinGW I'm afraid, but the Windows command prompt does support spaces in filenames. You just have to enclose the path in double quotes:
Code:
"folder\folder with space in its name\file"
Try pressing tab to autocomplete if in doubt.
Quote this message in a reply
Member
Posts: 89
Joined: 2005.06
Post: #8
I suggest taking a look at http://www.codeblocks.org. I think it integrates with MinGW. I use it currently for my project (the windows port) but I'm not writing it in Obj-C

Well since everyone else is doing it:
Twilight Coders
CIMyAdmin
Whatever
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #9
I actually tried enclosing in quotes since that is easy to find on the web, but it didn't work.

Last night I found out about autocomplete, and I found the command \f:on turns autocomplete on for all command-line windows, which interestingly doesn't autocomplete anything (I even checked the registry values to make sure tab really is the auto-complete key), but it allows me to use spaces and other "non-standard" keys in filenames without the need for quotes or any other trickery.

I'd still like to try and get XCode and MinGW working (or any GUI solution really), but autocomplete just made the command-line quite a bit more bearable. For GUI solutions, I've actually tried about 4 or 5 different gcc IDEs available for Windows, but they all only support C/C++ and setting -lobjc in the compiler options to force them to build Obj-C code only provides me with linking errors on all of them (despite gcc working just fine in the command-line).

Edit: Nevermind, I did more digging and found some good tutorials on MakeFiles, although I would still appreciate if someone could explain to me the differences between them, such as Make, CMake, CONS, ect.

There doesn't happen to be any programs that you can set some compiler options, give it a folder and it'll make a makefile for you, would there?
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #10
Another small update; I just tried out Code::Blocks like Volte suggested and while it doesn't support Obj-C, searching the forums there, people seem to think it's fully possible as its already build into gcc and Code::Blocks already supports adding other languages pre-built into gcc such as Fortran.

Unfortunately, nobody gave a very good explanation how and after trying my hand at it, all it does now is auto-generate a hash.h file that fails with about 150 errors (keep in mind this file is auto-generate by the gcc).

Add: Here's a good question. How can you make a Makefile compile output files into another directory? As it is, it compiles all the output files into the same directory the makefile is in and then builds the executable. I'd like to program it to compile and dump them into a "build" directory.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #11
Justin Brimm Wrote:Add: Here's a good question. How can you make a Makefile compile output files into another directory? As it is, it compiles all the output files into the same directory the makefile is in and then builds the executable. I'd like to program it to compile and dump them into a "build" directory.

Add "-o outputdir/mysourcefile.o" to the gcc args for each source file (where "mysourcefile" is the name of the file being compiled).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  can i write in c, c++ then compile with xcode and run in iphone? sefiroths 11 10,566 Dec 16, 2010 03:02 PM
Last Post: OptimisticMonkey
  Easy platform for computer board game Lizard Man 6 5,611 Jan 22, 2010 03:37 PM
Last Post: Blacktiger
  Easy game engine for Mac OS X YvanSoftware 7 11,593 Dec 17, 2009 03:04 PM
Last Post: SethWillits