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

From Second Life Wiki
Jump to navigation Jump to search
 
(83 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{Multi-lang}}
#REDIRECT [[Compiling the viewer (Mac OS X XCode 6.1)]]
{{CompileNav}}
 
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.
 
= Development Environment =
 
Most Lindens use XCode 3.0 on Leopard for building on Macintosh computers (though some still use XCode 2.4). 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.
<br />
<br />
= Installing Files =
 
== CMake (1.21 and later) ==
 
Install CMake 2.6.2 from [http://www.cmake.org cmake.org].
 
== Viewer Source ==
 
You can get source either from [[#Source Snapshot|a source snapshot tarball]], or [[#check out from the source control system]]:
 
=== Source Snapshot ===
 
Sources for each release are available on the [[source downloads]] page. 
 
If you have Stuffit installed on your system, it may automacially unstuff .gz, so use  tar xvf, without the z to extract the tar file. It may also automatically unzip files. Instead of clicking on the file link, right click on the file link and select Download Linked File which will keep .gz and .zip intact.
 
When you have downloaded, it create a working directory (the directory name must not contain any spaces - most Linden Lab developers use '''~/linden''') and unpack the snapshot (replace ''x.x.x.x'' with the version number of the snapshot you downloaded):
 
$ mkdir ''work-dir''
$ cd ''work-dir''
$ tar xvfz ''path-to-download/''slviewer-src-''x.x.x.x''.tar.gz
 
then proceed to [[#Viewer Libraries and Artwork]].
 
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 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.
 
=== Check Out From Source Control ===
 
To check out sources from the subversion source control system, choose a working directory name (the directory name must not contain any spaces - most Linden Lab developers use ''~/linden''), and check out the sources:
 
$ svn co ''repository-url'' ''work-dir''
 
where
;''repository-url''
:is the url for the appropriate branch; see '''TBD'''
;''work-dir''
:is the working directory name you have chosen (you do not need to create this directory before doing the checkout)
 
then proceed to [[#Viewer Libraries and Artwork]].
 
== Viewer Libraries and Artwork ==
 
'''If you are building Snowglobe from source, you can use a script provided with the source code which automatically downloads and installs all artwork and libraries (except for the fmod library):'''
 
$ ./scripts/public_fetch_tarballs.py
 
then skip to ''TBD''.
 
=== Manual Downloads ===
 
The required pre-compiled third-party libraries, and artwork files are available from the [[source downloads]] page.  Download the Mac library package, and the Artwork zip file. 
 
Unpack them into the working directory that you created in the [[#Viewer Source]] step. The directory that you work in should should have no spaces in the name. For example, from the directory where you downloaded the tarballs :
 
$ tar xvfz ''path-to-downloads/''slviewer-darwin-libs-''x.x.x.x''.tar.gz
$ unzip ''path-to-downloads/''slviewer-artwork-''x.x.x.x''.zip
 
If you have Stuffit installed on your system, it may automacially unstuff .gz, so use  tar xvf, without the z to extract the tar file. It may also automatically unzip files. Instead of clicking on the file link, right click on the file link and select Download Linked File which will keep .gz and .zip intact.
 
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 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 From Scratch (Optional) ==
 
For convenience, Lindens package up the libraries they are allowed to distribute so you can download and unpack them into your development working directory. The [[#Viewer Source, Libraries, and Artwork|above procedure]] installs pre-compiled third-party library files.  Alternatively, if you want to build the libraries yourself, See [[Compiling the viewer libraries (Mac OS X)|another page]].
 
== 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 ===
#Download & extract [http://www.fmod.org/files/fmod3/ fmod 3.75 programmers api for macintosh].
#*(You do *not* want the latest version)
#Copy the extracted files, combining the separate PowerPC and x86 libraries into a universal binary.
 
$ 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
 
= Building the Viewer with CMake =
[http://cmake.org 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 ==
 
#Go into the <code>linden/indra</code> directory, and run <code>develop.py</code>.
#Launch XCode, open the project file 'linden/indra/build-darwin-universal/SecondLife.xcodeproj',
#In XCode's project settings, set the base SDK to Mac OS X 10.6 (or 10.5, if you're not on Snow Leopard), and the compiler version to GCC 4.0.
#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 <code>develop.py</code> 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: <code>"./develop.py"</code>
** make: <code>"./develop.py -G 'Unix Makefiles'"</code>
 
'''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 <code>develop.py</code> script will create and populate a build directory for you, located in the <code>build-darwin-universal</code> directory.
 
To start a build,
# Run "./develop.py build"). 
 
-- or --
 
#  Change to the build directory (<code>build-darwin-universal</code>)
#  Run <code>make</code>
 
-- or --
 
#  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:
<pre>
build-darwin-universal/newview/RelWithDebInfo/Second Life.app
</pre>
 
If you change the kind of build you use, the intermediate directory will also change, e.g. from <code>RelWithDebInfo</code> to <code>Release</code>.
 
= 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 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.efnet.org #opensl)
* Ask for help on the [[SLDev|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|submitting patches]].
 
[[Category:Compiling viewer]]

Latest revision as of 11:30, 23 April 2015