Compiling the viewer (Mac OS X)

From Second Life Wiki
Revision as of 17:51, 13 January 2007 by Hunting Hare (talk | contribs) (clean up some minor gotchas, add reference to ADC for Universal)
Jump to navigation Jump to search

The following are instructions for building the Second Life viewer on Mac OS X. For other platforms, see Compiling the viewer

Development Environment

We use XCode 2.4.1 for building on Macintosh computers. For simplicity, we suggest installing everything from the mpkg.

You will need to install the proprietary libraries as well as all of the other third party libraries below. For convenience, we package up the libraries we are allowed to distribute so you can either download that package and unpack it into your development working directory or install all of the libraries from scratch.

Installing Proprietary Libraries

We do not distribute these libraries, so you will need to fetch and install these even if you download the libraries packages.

Fmod

  • Download & extract fmod 3.75 programmers api for macintosh.
  • (You do *not* want the latest version, instead scroll down to v3.75)
  • Copy the extracted files. Note the name change for the x86 library.
$ cp -p fmodapi375mac/api/inc/*.h linden/libraries/include
$ cp -p fmodapi375mac/api/lib/libfmod.a linden/libraries/powerpc-darwin/lib_debug
$ cp -p fmodapi375mac/api/lib/libfmod.a linden/libraries/powerpc-darwin/lib_release
$ cp -p fmodapi375mac/api/lib/libfmodx86.a linden/libraries/i386-darwin/lib_debug/libfmod.a
$ cp -p fmodapi375mac/api/lib/libfmodx86.a linden/libraries/i386-darwin/lib_release/libfmod.a

Installing Libraries

We supply a package of the required libraries and binaries on the compiling the viewer page.

From the directory where you downloaded the tarballs:

tar xvfz sl-source.tar.gz
tar xvfz sl-libraries.tar.gz

Your filenames may vary. If you open them with the double click file extract, remember that dragging folders on top of each other will overwrite the original contents, not merge them as in windows.

Installing Libraries From Scratch

We recommend creating a separate third party library directory named 'lindenlib' on the same level as the 'linden' tree in your directory structure. Download, unpack, and build from there and copy the files specified to their final location.

Most of the libs built here are architecture specific, so these instructions will refer to $PLATFORM to denote that. You can set an environment variable to make it so copy & paste from these instructions will work:

$ PLATFORM=`uname -p`-darwin

Building the Universal target requires that you have built both the i386 and ppc libraries. (Please see [1] for more background information.)

Using gcc 4.0 on a ppc box when building many of these libraries will insert an undefined reference to _fprintf$LBDLStub which then fails to link later. Until we have a better solution to this issue, you will need to use an earlier version of gcc. Some of the instructions below will include a call to gcc_select which is only necessary if you are building on a ppc box.

Boost

Download & extract Boost source. The viewer does not link to the boost libraries, so much of this is not necessary. You can simply copy the header files if you have problems getting the boost package to build.

Copy the Headers

$ cp -r lindenlib/boost-1.33.0/boost linden/libraries/include/boost

Build Boost.Jam

$ cd boost-1.33.0/tools/build/jam_src
$ ./build.sh
$ if [ $PLATFORM = "i386-darwin" ] then PLATDIR=bin.macosxx86; else PLATDIR=bin.macosxppc; fi
$ cp $PLATDIR/bjam ../../..
$ unset PLATDIR

Build Boost

$ cd boost-1.33.0/libs
$ export PYTHON_ROOT=/System/Library/Frameworks/Python.framework/Versions/2.3/
$ export PYTHON_VERSION=2.3
$ ./bjam stage

Copy the Libraries

$ sudo gcc_select 4.0
$ cd boost-1.33.0
$ export PLATFORM=`uname -p`-darwin
$ cp src/stage/lib/libboost_python-gcc.a \
libraries/$PLATFORM/lib_release
$ cp src/stage/lib/libboost_python-gcc-d.a \ 
libraries/$PLATFORM/lib_debug/libboost_python-gcc.a
$ cp src/stage/lib/libboost_python-gcc-mt.a \
libraries/$PLATFORM/lib_release
$ cp src/stage/lib/libboost_python-gcc-mt-d.a \
libraries/$PLATFORM/lib_debug/libboost_python-gcc-mt.a
$ cp src/stage/lib/libboost_regex-gcc.a \
libraries/$PLATFORM/lib_release
$ cp src/stage/lib/libboost_regex-gcc-d.a \
libraries/$PLATFORM/lib_debug/libboost_regex-gcc.a
$ cp src/stage/lib/libboost_regex-gcc-mt.a \
libraries/$PLATFORM/lib_release
$ cp src/stage/lib/libboost_regex-gcc-mt-d.a \
libraries/$PLATFORM/lib_debug/libboost_regex-gcc-mt.a

Apache Portable Runtime

  • Download & extract apr and apr-util.
  • Build and install the headers and lib files using a terminal.
$ sudo gcc_select 3.3
$ cd lindenlib/apr-1.2.8
$ ./configure --disable-shared --disable-lfs --prefix=/tmp/apr
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/apr/include/apr-1 linden/libraries/$PLATFORM/include
$ cp /tmp/apr/lib/libapr-1.a linden/libraries/$PLATFORM/lib_release
$ cp /tmp/apr/lib/libapr-1.a linden/libraries/$PLATFORM/lib_debug

$ cd lindenlib/apr-util-1.2.8
$ ./configure --disable-shared --disable-lfs --with-apr=/tmp/apr --prefix=/tmp/apr-util
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/apr-util/include/apr-1 linden/libraries/$PLATFORM/include
$ cp /tmp/apr-util/lib/*.a linden/libraries/$PLATFORM/lib_release
$ cp /tmp/apr-util/lib/*.a linden/libraries/$PLATFORM/lib_debug
$ sudo gcc_select 4.0

zlib

  • Download and extract zlib.
  • Build and install it.
$ sudo gcc_select 3.3
$ cd zlib-1.2.3
$ ./configure --prefix=/tmp/zlib
$ make
$ make install
$ cd ../..
$ cp -Rp /tmp/zlib/include linden/libraries/include/zlib
$ cp -p /tmp/zlib/lib/libz.a linden/libraries/$PLATFORM/lib_debug/libllz.a
$ cp -p /tmp/zlib/lib/libz.a linden/libraries/$PLATFORM/lib_release/libllz.a
  • Note that the library has a different name in the libraries directory.

Expat

  • Download an extract the 1.95.8 version of expat.
  • Build and install the library
$ sudo gcc_select 3.3
$ cd expat-1.95.8
$ ./configure --prefix=/tmp/expat
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/expat/include linden/libraries/include/expat
$ cp -p /tmp/expat/lib/libexpat.a linden/libraries/$PLATFORM/lib_release
$ cp -p /tmp/expat/lib/libexpat.a linden/libraries/$PLATFORM/lib_debug

XMLRPC-epi

$ sudo gcc_select 3.3
$ cd xmlrpc-epi-0.51
$ ./configure --disable-shared --prefix=/tmp/xmlrpc-epi
  • Apply patch 3 from the instructions in patch xmlrpc-epi.
  • Finish the removal of expat, build, and install
$ rm -rf expat
$ mkdir expat
$ cp /tmp/expat/include/* expat
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/xmlrpc-epi/include linden/libraries/include/xmlrpc-epi
$ cp -p /tmp/xmlrpc-epi/lib/libxmlrpc.a linden/libraries/$PLATFORM/lib_release
$ cp -p /tmp/xmlrpc-epi/lib/libxmlrpc.a linden/libraries/$PLATFORM/lib_debug

JPEGlib

  • Download & extract jpeglib. You will minimally need jpegsrc.v6b.tar.gz.
  • Build and install the library:
$ sudo gcc_select 3.3
$ cd jpeg-6b
$ ./configure
$ make
$ cd ../..
$ mkdir linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/jconfig.h linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/jerror.h linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/jinclude.h linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/jmorecfg.h linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/jpeglib.h linden/libraries/include/jpeglib
$ cp lindenlib/jpeg-6b/libjpeg.a linden/libraries/$PLATFORM/lib_debug/liblljpeg.a
$ cp lindenlib/jpeg-6b/libjpeg.a linden/libraries/$PLATFORM/lib_release/liblljpeg.a
  • Note that the library has a different name in the libraries directory.
  • If you plan to use the header file from windows, you will need to patch jpeglib using any terminal.

OpenJPEG

  • Download and extract version 1.0 openjpeg source.
  • Copy the linden openjpeg makefiles into the openjpeg source top level directory. We do this to maintain 10.3.9 compatibility.
  • Build and install the library
$ sudo gcc_select 3.3
$ mkdir ../../linden/libraries/include/openjpeg
$ cp -p libopenjpeg/openjpeg.h ../../linden/libraries/include/openjpeg
$ make -f Makefile-i386.ppc libopenjpeg.a
$ cp libopenjpeg.a ../../linden/libraries/ppc-darwin/lib_debug
$ cp libopenjpeg.a ../../linden/libraries/ppc-darwin/lib_release
$ make -f Makefile-i386.ppc clean
$ make -f Makefile-i386.osx libopenjpeg.a
$ cp libopenjpeg.a ../../linden/libraries/i386-darwin/lib_debug
$ cp libopenjpeg.a ../../linden/libraries/i386-darwin/lib_release

Freetype

  • Download and extract FreeType.
  • Build and install the FreeType library:
$ sudo gcc_select 3.3
$ cd freetype-2.2.1
$ ./configure --prefix=/tmp/freetype
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/freetype/include/freetype2/freetype linden/libraries/include
$ cp -p /tmp/freetype/include/freetype2/ft2build.h linden/libraries/include
$ cp -p /tmp/freetype/lib/libfreetype.a linden/libraries/$PLATFORM/lib_release
$ cp -p /tmp/freetype/lib/libfreetype.a linden/libraries/$PLATFORM/lib_debug


Vorbis & Ogg

  • Download & extract libvorbis.
  • Download & extract libogg.
  • Build & copy libogg first:
$ sudo gcc_select 3.3
$ cd libogg-1.1.3
$ ./configure --prefix=/tmp/ogg
$ make
$ make install
$ cd ../..
$ cp -pR /tmp/ogg/include/ogg linden/libraries/include
$ cp -p /tmp/ogg/lib/libogg.a linden/libraries/$PLATFORM/lib_debug
$ cp -p /tmp/ogg/lib/libogg.a linden/libraries/$PLATFORM/lib_release
  • Build & copy libvorbis:
$ sudo gcc_select 3.3
$ cd libvorbis-1.1.2
$ ./configure --prefix=/tmp/vorbis --with-ogg=/tmp/ogg
$ make
$ make install
$ ../..
$ cp -pR /tmp/vorbis/include/vorbis linden/libraries/include
$ cp -p /tmp/vorbis/lib/libvorbis*.a linden/libraries/$PLATFORM/lib_debug
$ cp -p /tmp/vorbis/lib/libvorbis*.a linden/libraries/$PLATFORM/lib_release

TUT

  • Download tut into lindenlib
  • Move it into a sub-directory, extract, and copy the headers
$ mkdir tut
$ mv TUT-2006-11-04.tar.gz tut
$ cd tut
$ tar xvzf TUT-2006-11-04.tar.gz
$ cd ../..
$ mkdir linden/libraries/include/tut
$ cp -p lindenlib/tut/tut.h lindenlib/tut/tut_reporter.h lindenlib/tut/tut_restartable.h linden/libraries/include/tut

Mozilla

*FIX: It's really hard to build the mozilla libs. Instructions coming.

Building the Viewer

Launch XCode, open the project file 'linden/indra/newview/macview.xcodeproj', set 'newview' as the active target, select an active build configuration, and build the project.

If you had to change gcc versions for a ppc build, restore gcc back to 4.0.

$ sudo gcc_select 4.0

Build Configurations

  • Development: This configuration is more suitable for debugging. The build process will create the SecondLife application targeted for your host architecture.
  • Deployment: This configuration is faster than the development version at the cost of some ability to debug. The build process will create the SecondLife application targeted for your host architecture.
  • Universal: This configuration is the same as the Deployment target except that all supported architectures - ppc and i386 - are built.

Building the Unit Tests

From XCode, open the project 'linden/indra/test/MacTester.xcodeproj', set 'MacTester' as the active target, and build.