Tuesday, 7 July 2009

HOWTO: compile source code on MAC OS X


Macport (recommended, can be found on apple.com, updated and organized well) and Fink are installed in default locations, /opt/local and /sw.

Note: Fink is buggy, normally reinstallation on the previous version will not work, issues like path setup maybe occur, either bin files or libraries are not accessible.

To compile:
  1. For library invoking:
    export LDFLAGS='-L/usr/local/lib -L/usr/lib -L/opt/local/lib -L/sw/lib'
    - '-L/dir' is the convention to setup gcc switch, while -L for make is --check-symlink-times, useless for me :)
    - Official way for invoking library is to setup $DYLD_LIBRARY_PATH (export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/opt/local/lib:/sw/lib), which in Linux is $LD_LIBRARY_PATH by default.
    - Normally lib path don't need specified, because the bin files (in /usr/bin or /opt/local/bin' will know where to get appropriate libraries, no matter bin files from Macports or Fink.

  2. For header files invoking:
    export CPPFLAGS='-I/usr/local/include -I/usr/include -I/opt/local/include -I/sw/include'
    - This is the way to setup both 'make' and 'gcc' switch, which is 'make -I/usr/local/include'.

The following are what I typed in terminal with user root to compile GNUstep-0.22.

export CPPFLAGS='-I/usr/local/include -I/opt/local/include'
export LDFLAGS='-L/usr/local/lib -L/usr/lib -L/opt/local/lib -L/sw/lib'
export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/opt/local/lib:/sw/lib:/usr/GNUstep/Local/Library/Libraries
. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh

No comments:

My photo
London, United Kingdom

Facebook & Twitter