Difference between revisions of "Compiling the viewer (Mac OS X)"

From Second Life Wiki
Jump to navigation Jump to search
Line 45: Line 45:
=== Fmod ===
=== Fmod ===
#Download & extract [http://www.fmod.org/files/fmod3/fmodapi375mac.zip fmod 3.75 programmers api for macintosh] (later versions, like FMOD Ex, are incompatible).
#Download & extract [http://www.fmod.org/files/fmod3/fmodapi375mac.zip fmod 3.75 programmers api for macintosh] (later versions, like FMOD Ex, are incompatible).
#Copy the extracted files, combining the separate PowerPC and x86 libraries into a universal binary. In a Terminal session, navigate to the folder containing the extracted fmod package and type the following cmmands:
#Copy the extracted files to folder containing your linden local repository. Now you'll need to combine the separate PowerPC and x86 libraries into a universal binary and copy the result to the libraries folder. In a Terminal session, navigate to the folder containing the extracted fmod package and type the following commands:


  mkdir -p ''linden/''libraries/include
  mkdir -p ''linden/''libraries/include
Line 54: Line 54:
  touch -r fmodapi375mac/api/lib/libfmodx86.a ''linden/''libraries/universal-darwin/lib_debug/libfmod.a
  touch -r fmodapi375mac/api/lib/libfmodx86.a ''linden/''libraries/universal-darwin/lib_debug/libfmod.a
  cp -p ''linden/''libraries/universal-darwin/lib_debug/libfmod.a ''linden/''libraries/universal-darwin/lib_release/libfmod.a
  cp -p ''linden/''libraries/universal-darwin/lib_debug/libfmod.a ''linden/''libraries/universal-darwin/lib_release/libfmod.a
It's a good practice to create that libraries hierarchy once somewhere and copy it over a freshly checked out repo.


= Building the Viewer with CMake =
= Building the Viewer with CMake =

Revision as of 17:09, 9 July 2010

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

You will also need to check the Build Notes column of the table on source downloads page.

Getting Development Tools

  • XCode : Most Lindens use XCode 3.1 on Leopard (OS X 10.5) for building on Macintosh computers (though some still use XCode 2.4). For simplicity, we suggest installing everything from the mpkg.
  • CMake : Install CMake 2.6.2 from cmake.org.

Downloading Source Code

You can download the Viewer source code on the source downloads page. You can also use a version control repository. If you're just starting out, it's probably best to get the latest Release version, rather than a Release Candidate, because the Release Candidates get updated quite often. But if you would rather work with the latest code, go for the version control repository "trunk". Don't forget to also download the artwork and library bundles relevant to the repository branch you're using as explained in Artwork and Library Bundles.

If you're downloading from the source downloads page, there are three packages to get: the source package, the artwork package, and the library package. In versions 1.20 and earlier, Linden packaged the library binaries in the Libs package. For 1.21 and beyond, the CMake develop.py script now downloads most of the libraries that were previously in the libs zip file. This saves developers who are tracking trunk from constantly downloading them every update and only downloads updated libraries. As of this writing, there are some pieces packages that still require downloading, so be sure to grab the library and artwork bundles from the source downloads page.

Downloading Tarballs on Mac

If you have Stuffit installed on your system, it may automacially unstuff .gz files. In that case, use tar xvf (i.e. the regular command without the z) to extract the tar file. It may also automatically unzip files. To prevent these unpacking when downloading, instead of clicking on the file link in the source downloads page, right click on the link and select Download Linked File from the contextual menu which will keep .gz and .zip files intact.

When you have downloaded it, unpack the snapshot (replace x.x.x.x with the version number of the snapshot you downloaded). This creates the linden directory as a subdirectory of your current working directory:

tar xvzf path-to-download/snowglobe-src-viewer-x.x.x.x.tar.gz

The exact filenames will differ with the version number. If you open them with the double click file extract, remember that dragging folders on top of each other on Mac will overwrite the original contents, not merge them as in Windows.

Check the source downloads page for any special Build Notes associated with the viewer version, if any.

Installing Libraries and Artwork Bundles

The build requires a number of libraries and artwork files that must be downloaded separately and dropped in directories in the linden source tree.

The easiest method of doing this is to use the script described in Artwork and Library Bundles.

Installing Third Party Libraries

You can if you prefer install those libraries from scratch. For convenience, Linden Lab packages up the libraries they are allowed to distribute so you can download and unpack them into your development working directory. The [Version_control_repository#Artwork_and_Library_Bundles|Artwork and Library Bundles]] installs such pre-compiled third-party library files. Alternatively, if you want to build the libraries yourself, See Compiling the viewer libraries (Mac OS X).

Installing Proprietary Libraries

The Viewer depends on some proprietary libraries. Lindens do not distribute these libraries, so you will need to fetch and install these even if you download the libraries packages. (This is due to licensing restrictions. Don't ask, Lindens already did, and can't get permission. So you do have to get them yourself.)

Fmod

  1. Download & extract fmod 3.75 programmers api for macintosh (later versions, like FMOD Ex, are incompatible).
  2. Copy the extracted files to folder containing your linden local repository. Now you'll need to combine the separate PowerPC and x86 libraries into a universal binary and copy the result to the libraries folder. In a Terminal session, navigate to the folder containing the extracted fmod package and type the following commands:
mkdir -p linden/libraries/include
mkdir -p linden/libraries/universal-darwin/lib_debug
mkdir -p linden/libraries/universal-darwin/lib_release
cp -p fmodapi375mac/api/inc/*.h linden/libraries/include
lipo -create fmodapi375mac/api/lib/libfmod.a  fmodapi375mac/api/lib/libfmodx86.a  -output linden/libraries/universal-darwin/lib_debug/libfmod.a
touch -r fmodapi375mac/api/lib/libfmodx86.a linden/libraries/universal-darwin/lib_debug/libfmod.a
cp -p linden/libraries/universal-darwin/lib_debug/libfmod.a linden/libraries/universal-darwin/lib_release/libfmod.a

It's a good practice to create that libraries hierarchy once somewhere and copy it over a freshly checked out repo.

Building the Viewer with CMake

CMake is a system for generating per-platform build files. On OS X, it will generate your choice of Makefiles or Xcode project files.

NOTE: - these instructions only apply to version 1.21 and later of the Second Life viewer. For instructions about compiling earlier versions, please see Compiling the viewer (Mac OS X, 1.20 and earlier)

Quickstart

  1. Go into the linden/indra directory, and run develop.py.
  2. Launch XCode, open the project file "linden/indra/build-darwin-universal/SecondLife.xcodeproj",
    the universal in the above name is the platform type; depending on your version of Xcode, it may be a different value.
  3. In XCode's project settings, set the base SDK to Mac OS X 10.6 (NOTE: see [1]) (or 10.5, if you're not on Snow Leopard), and the compiler version to GCC 4.0.
  4. Build the project. This can take a very long time, depending on your system, but will likely use nearly 100% CPU for most of the process. Get a cup of coffee.

Build Configurations

Debug
This configuration is more suitable for debugging. The build process will create the SecondLife application targeted for your host architecture. Unoptimized, includes debug symbols.
RelWithDebInfo
Essentially the same as the Debug target without LL_DEBUG defined. This disables a significant amount of sanity checking which slows down the viewer. Unoptimized, includes debug symbols.
Release
Optimised, without debug info.

Configuring your tree

Before you first run a build, you'll need to configure things. There's a develop.py script that will create a reasonably sane default configuration for you.

From the command line, cd into the indra subdirectory and run one of the following commands (depending on your choice of platform and build environment):

    • XCode: "./develop.py"
    • make: "./develop.py -G 'Unix Makefiles'"

NOTE: The above commands will configure a "non-standalone" version of the source code tree. This means that the required third party library packages (as built by Linden Lab) will be downloaded during the CMake process.

Compiling

In the CMake world, we keep source and object files separate. The develop.py script will create and populate a build directory for you, located in the build-darwin-universal directory.

To start a build,

  1. Run "./develop.py build").

-- or --

  1. Change to the build directory (build-darwin-universal)
  2. Run make

-- or --

  1. Launch XCode, open the project file 'linden/indra/newview/build-darwin-universal/SecondLife.xcodeproj',

... and away you go!

Where's the built viewer?

On OS X, your viewer build will be here by default:

build-darwin-universal/newview/RelWithDebInfo/Second Life.app

If you change the kind of build you use, the intermediate directory will also change, e.g. from RelWithDebInfo to Release.

Building the Unit Tests

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

What to do if it doesn't work for you

  • Check your environment. Ensure you have the OS X 10.6 (NOTE: see [2]) or 10.5 SDK selected and installed (reinstall XCode if needed to get it) and have set the Compiler Version to GCC 4.0 in XCode's Project Settings.
  • If the build complains of missing proprietary libraries, such as libopenal.dylib, you may need to copy them manually to the location the build scripts expect them to be.
  • If you can't find certain files that the build process expects, you can copy them an already-compiled version of the viewer. You can do this by looking inside the viewer's application package [right click > Show Package Contents]. This applies equally to branched or third-party variants of the viewer which may have additional dependencies.
  • Ask for help on IRC (irc.freenode.net #opensl)
  • Ask for help on the SLDev mailing list
  • Fix it: Modifying CMake Files‎ (and please, submit a patch!)

Submitting Patches

This is probably far down the road, but if you make changes to the source and want to submit them, see the page about submitting patches.