Author Topic: Compiling OpenXCOM on Mac OS X  (Read 41204 times)

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Compiling OpenXCOM on Mac OS X
« on: May 16, 2010, 12:49:01 am »
!!! WARNING !!!
This guide is effectively OBSOLETE and is not supported anymore. Please, use it for historical purposes only - to possibly get a better idea how the process works, but not for the actual compiling itself.
To succeed with you own build, follow the new guide instead - https://openxcom.ninex.info/forum/index.php?topic=127.0

-------
After some fiddling with XCode on my native 64-bit Snow Leopard (10.6.3) I've finally succeeded in building the source. There were (and still are) some peculiarities though. So, how did I do that?
First of all, you need the prerequisites installed. Those would be:
* SDL.framework
* SDL_mixer.framework
* SDL_gfx.framework

You can fetch the first and second one here:
https://www.libsdl.org/release/SDL-1.2.14.dmg
https://www.libsdl.org/release/SDL-devel-1.2.14-extras.dmg
https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.11.dmg

The problem, however, lies with SDL_gfx, for there is no official precompiled package - you have to create it yourself. However, if you find the process dull or intimidating - here is a precompiled latest version (SVN r45) built by me - https://www.mediafire.com/?h4gor8qrggcc2nw

Also, after the r104 release of OpenXcom - it turned out that 64-bit support in most of those frameworks was kind of messed up, so I had to manually recompile them to get things working again. If you happen to stumble upon the same issues - here goes a bundle of everything you might need - https://www.mediafire.com/?8c69mvblmzod73w
After you have finally got all three frameworks installed (presumably in /Library/Frameworks/) - create a new project in Xcode and select User Templates > Application > SDL Application. Name it "openxcom" (without quotes of course).
Now we have to configure access to SVN-repository so we can stay up to date with project's contributions.
Go to SCM > Configure SCM Repositories > + and enter a name (I chose "OpenXcom") and type (Subversion) for your new repo. Now the tricky part!!! Add THIS address to the URL field -
https:https://openxcom.svn.sourceforge.net/svnroot/openxcom. For some reason the URL given by SupSuper didn't quite work - showed an error.
Once the repo is set up, click SCM > Repositories > "newly added repo" and you should automatically connect to it. Click on "trunk" folder and then execute "Checkout" command from the toolbar. Save the "trunk" folder inside your project folder (that would be "openxcom").
Next, go to Project > Select Project Settings > General and click "Configure Roots & SCM". Under "Root" tab enter "trunk" (without quotes) and your repo will be suggested automatically. Ok.
Right-click on "openxcom" project tree in the left pane of main window and select Add > Existing Files > path to "openxcom" > trunk.

Ok, SVN is set and in sync, now you have to add yet missing frameworks to your project. Right-click on Frameworks > Linked Frameworks folder in the left pane and select Add > Existing Frameworks > SDL_mixer.framework and then follow the same procedure to import SDL_gfx.framework. Next, drag-n-copy those frameworks from "Linked Frameworks" to "Targets > openxcom > Copy Frameworks into .app bundle" to make the bundle self-sustainable.

Then, go to Project > Edit Project Settings > Build and make sure that in "Search Paths" section you have the following strings:
Corresponding to "Header Search Paths" you should add "$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers", "/Library/Frameworks/SDL_mixer.framework/Headers", "$(HOME)/Library/Frameworks/SDL_gfx.framework/Headers", "/Library/Frameworks/SDL_gfx.framework/Headers".

One more thing  - go up the list in this tab, select "All Configurations" from the "Configuration" drop-down menu, and corresponding to "Base SDK" key choose "Mac OS X 10.6" value. This will make sure that your program will use the latest features provided by OS X. However, if you want your app to be reasonably backwards-compatible make sure to select earlier target value (my recommendation would be 10.5.) corresponding to "Mac OS X Deployment Target" key.

Now we want to make sure that the original game data we feed to this engine will be read from within the bundle's "Resources/DATA" folder, so our game is fully self-contained OSX-style. You have to edit "SDLMain.m" file (click on "Classes" folder in the left pane of you Xcode project window) as described here https://meandmark.com/blog/2009/12/sdl-tips-for-mac-os-x/.

Ok, now you can choose "Build" command from the menu and hopefully see everything compile without a hitch (due to many reasons your experience may vary, of course :)

Find your newly built app, open it (right click on it > Show Package Contents > Contents > Resources > DATA) and put the original UFO Defense data folder tree (I had the Windows version, but DOS data should work as well) there and you are done.

Now you can click on your app, and if everything was done right - you should experience some oldschool wonder. Enjoy! ;)

P.S. For those of you who have troubles with this setup - here is a precompiled binary (constantly updated), created by following the aforementioned step-by-step guide.
v. 0.1 (upd) (SVN r214) - https://www.mediafire.com/?p1wh3l7195kfpqr
« Last Edit: January 13, 2011, 11:08:20 am by marabus »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #1 on: May 19, 2010, 03:47:19 am »
Thanks for the help, I've put up your build (can't try it myself though) and link to the instructions on the website if that's ok with you. :)
Go to SCM > Configure SCM Repositories > + and enter a name (I chose "OpenXcom") and type (Subversion) for your new repo. Now the tricky part!!! Add THIS address to the URL field -
https:https://openxcom.svn.sourceforge.net/svnroot/openxcom. For some reason the URL given by SupSuper didn't quite work - showed an error.
I've corrected the link now, you could've also used https:https://openxcom.svn.sourceforge.net/svnroot/openxcom/trunk/ to avoid the subfolder.

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #2 on: May 20, 2010, 12:07:41 am »
That's perfectly fine with me. In fact, I am eager to help you with this one, if you don't mind. I am in possession of iMac with OSX on it (obviously), and I'm very interested in your progress on this project, so it's mostly scratching my own itch here  :D
And of course, I can help with some testing/bug-spotting too. Not much on a programming side though. Not yet, at least  :(

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #3 on: May 24, 2010, 12:41:08 pm »
Someone posted this on another forum:
Quote from: dan2
When I attempted to run Openxcom, it gave an error saying I might not have the right OSX for it. I have 10.6.3, do you know what version do I need to make it work?

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #4 on: May 24, 2010, 04:01:52 pm »
Someone posted this on another forum:
Quote from: dan2
When I attempted to run Openxcom, it gave an error saying I might not have the right OSX for it. I have 10.6.3, do you know what version do I need to make it work?


It seems I've left a build option "active architectures only" for that previous build. And since my working arch is x86_64 - that quite possibly may be the culprit. I'm going to make a new build with more compatibility turned on. However, there is a file missing in the trunk - https://openxcom.ninex.info/index.php/2010/05/random-numbers-suck/#comments and thus I'm stuck at this point until it reemerges there  ::)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #5 on: May 24, 2010, 09:51:02 pm »
Someone posted this on another forum:
Quote from: dan2
When I attempted to run Openxcom, it gave an error saying I might not have the right OSX for it. I have 10.6.3, do you know what version do I need to make it work?


It seems I've left a build option "active architectures only" for that previous build. And since my working arch is x86_64 - that quite possibly may be the culprit. I'm going to make a new build with more compatibility turned on. However, there is a file missing in the trunk - https://openxcom.ninex.info/index.php/2010/05/random-numbers-suck/#comments and thus I'm stuck at this point until it reemerges there  ::)
I have saved the missing file. :)

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #6 on: May 24, 2010, 11:32:19 pm »
I hope my new build will fix the problem.
* The guide is updated as well - please, read it thoroughly - now you put data files INSIDE the bundle (Resources/DATA).

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #7 on: May 31, 2010, 04:38:44 am »
I finally had a chance to get on a Mac and try this myself. Here's some issues I ran into:

Running your build: The application only includes the SDL.framework, it's missing SDL_mixer.framework and SDL_gfx.framework.

Compiling it myself: I got the application and all the frameworks set up fine. My only problem is SDL_gfx. I figured out how to compile the source into a framework with Xcode, my only problem is it's stuck building only for "i386" architecture, even though Active Architectures Only is disabled and all the available Architectures seem to be listed. Any idea what the problem might be?

Also, regarding this step:
Quote
One more thing  - go up the list in this tab, select "All Configurations" from the "Configuration" drop-down menu, and corresponding to "Base SDK" key choose "Mac OS X 10.6" value.
I set it to "Mac OS X 10.4" and that seemed to work fine. If that affects backwards compatibility, I'd like if it worked on as many versions as possible.


Everything else seems fine though. :) I might commit the Xcode project once this is done to save all those steps.
« Last Edit: May 31, 2010, 04:43:09 am by SupSuper »

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #8 on: May 31, 2010, 11:45:29 pm »
+Guide updated

Quote
Running your build: The application only includes the SDL.framework, it's missing SDL_mixer.framework and SDL_gfx.framework.
Sorry, my bad. Fixed!

Quote
my only problem is it's stuck building only for "i386" architecture,
Architectures = Standard (32/64-bit Universal)
Valid Architectures = list all requested archs
Clean all targets and try to build again. Should help.
Please note, in order to have all the headers copied into .framework bundle you should check them as "Public" in "Targets > SDL_gfx > Copy Headers".

Quote
I set it to "Mac OS X 10.4" and that seemed to work fine.
It seems you have Leopard (10.5) installed. On my Snow Leo, the 10.4 SDK is deprecated, so my best shot here would be to choose 10.5. Yet this is unnecessary, sinse "Base SDK" key has nothing to do with compatibility - it only determines what new features you can employ. To set the app to be backwards-compatible you should check the version needed corresponding to "Mac OS X Deployment Target" key. More on that here - https://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/cross_development/Introduction/Introduction.html
Of course, setting compatibility to some obscure version would need all the dependent frameworks to be recompiled with those options in mind, and that is quite an achievement. To be concise, I recommend to set backwards-compatibility to some *reasonable* level, say one step back from current OSX version deployed by Apple. In our case that would be 10.5, 32/64-bit UB and of course - Intel-only. That's because most of Mac-lovers are already here, and if someone needs 10.1 PPC variant - they will have to follow my guide and compile the app themselves - I see no point in supporting all the possible architectures officially.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #9 on: June 02, 2010, 12:53:13 pm »
I got it all working now. :) Seemed a bit slow, but that might just be crappy university Macs at work...

And as long as it works on typical Mac systems I'm happy, I just wanted to make sure it ran on more than the latest brand new updated state-of-the-art Mac OS X or something... thanks for clearing that up. I'll put up my Xcode project soon for any other Mac users, although it's still not my platform of choice so you can keep maintaining and testing it. ;)


P.S. The README in the SVN is meant for developers, so not sure if it's worth including in builds, it might just confuse users.

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #10 on: June 02, 2010, 08:48:23 pm »
Quote
so you can keep maintaining and testing it.
My pleasure!  8)

Concerning README - I see no problem there, since common users will never download source code in the first place. So only developers will read it, as intended.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #11 on: June 03, 2010, 01:16:39 am »
Quote
so you can keep maintaining and testing it.
My pleasure!  8)

Concerning README - I see no problem there, since common users will never download source code in the first place. So only developers will read it, as intended.
Well I found it in the Resources of your Mac build, which is why I mentioned it. ;)

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #12 on: June 03, 2010, 07:14:15 am »
Oops.  :D

Offline luciderous

  • Colonel
  • ****
  • Posts: 108
  • There is no spoon...
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #13 on: July 13, 2010, 09:56:31 pm »
SVN build 99 does not compile correctly. Currently it says:
openxcom/trunk/StartState.cpp:100: error: expected primary-expression before '}' token
openxcom/trunk/StartState.cpp:100: error: expected `;' before '}' token

That's line 100, a parenthesis right after "default:" statement. Seems something went missing there. BTW, the previous 98 build compiled just fine, so this could possibly be related to some later cleanups.





Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Re: Compiling OpenXCOM on Mac OS X
« Reply #14 on: July 13, 2010, 10:17:43 pm »
SVN build 99 does not compile correctly. Currently it says:
openxcom/trunk/StartState.cpp:100: error: expected primary-expression before '}' token
openxcom/trunk/StartState.cpp:100: error: expected `;' before '}' token

That's line 100, a parenthesis right after "default:" statement. Seems something went missing there. BTW, the previous 98 build compiled just fine, so this could possibly be related to some later cleanups.
Should be fixed now, these cleanups never seem to end. :P

Would you mind making a new Mac build soon? I hope to put some new out eventually.