Compiling in Mac OS X

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Compiling for Mac OS X is not hard; someone else has already gone through the pain of compiling all dependencies and utilities. Compiling requires an Intel Mac.

  1. Download the Source
  2. You could in theory probably use FB 1.09, because our Mac port of FB was merged into FB 1.09, but we haven't tested it. However, there's no official build of FB for Mac, and the official FB bootstrap build (which has fbc transcompiled to C so that it doesn't need a copy of FB to compile) *doesn't include Darwin (Mac OSX)*, so you'll need an existing Mac build of FB to compile FB, or create your own bootstrap package (by modifying its makefile and compiling it under Linux/BSD/Windows)
    • Alternatively you can download a build of FB pre-1.06 [1]. This is a fork of FB. (The obsolete sources for that old 20160505 build are here).
    • Either make sure that the fbc executable is in your PATH, or pass the fbc argument to scons (or set FBC environment variable) to point to it.
  3. Install the SDL 1.2 and SDL_mixer 1.2 and/or SDL 2.0 and SDL_mixer 2.0 frameworks, depending on whether you want to compile gfx_sdl/music_sdl (which are obsolete) or gfx_sdl2/music_sdl2 (the default) backends.
    • scons looks for the frameworks both in /Library/Frameworks and ~/Library/Frameworks, or calls sdl-config.
  4. There may be other ways to install scons, but what worked for me was to install MacPorts and then run sudo port install scons, or install Homebrew and run brew install scons.
  5. In the main 'wip' directory, run 'scons' as usual, or 'scons .', etc. All targets should work (hspeak requires Euphoria)
  6. Run ./bundle-apps.sh to produce OHRRPGCE-Custom.app and OHRRPGCE-Game.app. This is optional; you can just run ohrrpgce-custom and ohrrpgce-game directly
  7. You can run ./distrib-mac.sh to package a distribution.

C/C++/Objective-C compiler[edit]

You need clang or an Apple gcc compiler to compile objective-C code (mac/SDLMain.m) because the system headers use blocks, which aren't supported by FSF GCC without Apple's patch for blocks added. For example GCC from macports doesn't work. clang does support blocks. XCode 4.2/GCC 4.2.1 is tested and confirmed working.

Versions Gorgonzola and earlier required gcc to compile FB code translated to C (clang masquerading as gcc did not work), but the releases starting with hróðvitnir and later can be compiled with clang. gcc is still used instead of clang if it is in the PATH. Run scons compiler=clang to prefer clang.

(Note for old versions: It is actually possible to use one compiler ('GCC') for FB code translated to C, and a different compiler ('CC') for the C/C++/Objective-C code (any version of Apple gcc or clang or gcc-clang) like so:

 CC=clang GCC=/opt/local/bin/gcc scons

XCode 4.2/Apple GCC 4.2.1, and GCC 4.9.3 from MacPorts are both known to work.)

Things you don't need to compile[edit]

mac/utilities.tar.gz and mac/utilities-x86_64.tar.gz also includes x86 and x86_64 builds (not fat binaries) of madplay and oggenc.

wip/mac/Frameworks.tar.gz contains x86-only builds of SDL and SDL_mixer; SDL.Framework is also missing headers to reduce its size. SDL_mixer has had a patch applied (see below) to fix Midi looping, though more recent SDL_mixer released have this fixed. Good luck trying to configure the Xcode projects to compile for Intel only.

FB 0.22 Mac port[edit]

Obsolete.png
This article (or part thereof) is obsolete. It may have made sense in the past, but it does not make sense now. It is kept here only for historic curiosity and/or posterity.

This information about the original port of FB 0.22 to OSX is preserved here for the moment.

Build of unofficial Mac port of FreeBASIC 0.22: [2]

Lately only compiling on OS 10.7 with XCode 4.2/GCC 4.2 has been tested, though all other versions of Mac OS should work too (only with a recent GCC?). OS 10.6 and 10.5 have previously been used; 10.4 has never been tested. 10.3 and older are PPC-only.

Compiling with support for older versions of Mac OS[edit]

(This section is out of date or incorrect)

By default compiling C code on OS 10.6+ will produce binaries that won't run on OS 10.4 and 10.5. To rectify this, you need a compatible build of FB, a compatible build of Euphoria, and have the OS 10.4 (recommended) or 10.5 SDK installed. Sadly you can't install these SDKs via more recent XCode versions; officially they are no longer supported, though they still seem to work.

  • FB for OS 10.4+: fixme
  • Euphoria 4.0.5 for OS 10.4+: [3]
(Note: the euc in this Euphoria build assumes that the OS 10.4 SDK is installed at /Developer/SDKs/MacOSX10.4u.sdk. If you want to compile on an actual 10.4/5 system without the SDK, get euc to generate a makefile and remove the -isysroot flag in it.

Compile with scons macsdk=10.4 or other Mac OSX SDK.

Actually you can use this FB build on all Intel Macs, but it produces annoying warning messages if not used in combination with with macsdk argument, and might not link correctly?

GPL Compliance[edit]

Future work[edit]

It might be nice to package games for Mac as .pkg Installers instead of .tar.gz files. These can be created on other OSes using a few simple programs (cpio, xar, gzip, bomutils):

http://bomutils.dyndns.org/tutorial.html http://krypted.com/mac-os-x/inspecting-creating-mac-installer-packages-linux/