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

From Second Life Wiki
Jump to navigation Jump to search
(→‎Getting Development Tools: cmake 2.8 works just fine, and you can get it from macports, too)
Line 5: Line 5:
= Getting Development Tools =
= 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.  Note that later versions of Xcode have build options to be backwards compatible to 3.1.  (See [[Talk:Compiling_the_viewer_(Mac_OS_X)#Trying_newer_versions_of_tools]].  Later versions of Xcode (3.2.4) work fine.)
* '''Xcode''': Most Lindens use Xcode 3.2 on Snow Leopard (OS X 10.6) for building on Macintosh computers. For simplicity, we suggest installing everything from the mpkg.  Note that later versions of Xcode have build options to be backwards compatible to 3.1.  (See [[Talk:Compiling_the_viewer_(Mac_OS_X)#Trying_newer_versions_of_tools]].  Later versions of Xcode (3.2.4) work fine.)
 
* '''CMake''': Install CMake from [http://www.cmake.org cmake.org], or using [http://macports.org/ MacPorts] with 'port install cmake'. You will need at least CMake 2.6; CMake 2.8 may be required in the future.
* '''CMake''': Install CMake from [http://www.cmake.org cmake.org], or using [http://macports.org/ MacPorts] with 'port install cmake'. You will need at least CMake 2.6; CMake 2.8 works just fine as well.
*'''Command line Makefiles''':  These are included in Apple's Xcode product.  Download and install Xcode from Apple.
*'''Command line Makefiles''':  These are included in Apple's Xcode product.  Download and install Xcode from Apple.


Line 16: Line 15:
If you're just starting out, it's probably best to get ''viewer-release'' or ''viewer-beta'' , because ''viewer-developer'' gets updated several times per week.  But if you would rather work with the latest code, look for the latest builds on [[Project Snowstorm]] and ''viewer-developer'' on bitbucket.
If you're just starting out, it's probably best to get ''viewer-release'' or ''viewer-beta'' , because ''viewer-developer'' gets updated several times per week.  But if you would rather work with the latest code, look for the latest builds on [[Project Snowstorm]] and ''viewer-developer'' on bitbucket.


== Downloading Tarballs on Mac ==
:''The recommended process is to check out source from the Mercurial (hg) source control system rather than downloading tarballs; if that is what you're doing, skip this section.''
If you have Stuffit installed on your system, it may automacially unstuff .gz files. In that case, use <code>tar xvf</code> (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 ==
When you use the mercurial repository, many (all?) of the libraries you need will be downloaded by magic.  Otherwise, you might have to download individual libraries.  The instructions below might be helpful.
Libraries and artwork files  must be      dropped in directories in the ''linden'' source tree.  (The directory is not called ''linden'', that is just a placeholder name.)
The easiest method of doing this is to use the script described in [[Version_control_repository#Artwork_and_Library_Bundles|Artwork and Library Bundles]].
== Installing Third Party Libraries ==
You can  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 ==
== 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.)
Some builds of the the Viewer depends on proprietary libraries (alternative open source libraries are also provided for developers who prefer or are not licensed to use the 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 ===
=== 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).
(instructions needed)
#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. (Probably not. Universal builds are not longer supported by the viewer.)   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 smart practice to create that libraries hierarchy once somewhere and copy it over a freshly checked out repo.
 
= Building the Viewer =
A build can take about an hour.  [http://cmake.org CMake] is a standard system for generating per-platform build files using platform independent scripts. On OS X, it will generate your choice of Makefiles or Xcode project files. The build uses  <code>develop.py</code> that invokes CMake for you and takes care of other tasks like downloading the 3rd party libraries.
 
See below instructions for setting up an Xcode environment ''or'' a command line Unix Makefile style environment.


:'''NOTE:''' These instructions only apply to version 1.21 and later of the Second Life viewerFor instructions about compiling earlier versions, please see [[Compiling the viewer (Mac OS X, 1.20 and earlier)]]
== Build the viewer with autobuild ==
Configuring and building with autobuild works the same on all platformsFull instructions may be found at [[Build_Viewer_With_Autobuild]].


== Xcode ==
== Xcode ==


* In a Terminal window, navigate to your local <code>''linden/''indra</code> directory, and type the following command:
If you  have followed the configure instructions from [[Build_Viewer_With_Autobuild]], the directory ''build-darwin-i386'' will have been created in the root of your source distributionInside that directory you will find the ''SecondLife.xcodeproj'' project file which can be used with Xcode.  When opened it should be configured correctly to build, so just '''Build and Run'''.
 
<code>python develop.py</code>
 
* Launch Xcode and open the project file <code>linden/indra/build-darwin-i386/SecondLife.xcodeproj</code>.
Note that for all branches starting with 2.0, only the Mac Intel platform (i386) is supported.
* In Xcode, select the SecondLife project (top of the left bar), click "Info" in the tool bar
** Select the "Build" tab (second from top left)
** Select ''RelWithDebInfo'' in the "Configuration" drop down
** Under the "Architectures" sub panel, set the base SDK to your version of Mac OS X (e.g., 10.6 (see [http://jira.secondlife.com/browse/SNOW-223]) or 10.5.
** Under the "Compiler Version" sub panel, set the compiler version to GCC 4.0.
* Click on the "Build" button on the top toolbar to build the new viewerFull build can take a long time. Select the "Build" tab in the work area so you can follow what's going on), but will likely use nearly 100% CPU for most of the process.
 
==Make ==
If instead, you prefer Unix style,
 
* In a Terminal window, navigate to your local <code>''linden/''indra</code> directory, and type
 
<code>python develop.py -G 'Unix Makefiles'</code>
 
'''NOTE:''' The above command 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.
 
* To start the build, you can still use <code>develop.py</code>:
 
<code>python develop.py build</code>
 
-- or --
 
* Navigate to the build directory and invoke make
 
<code>cd build-darwin-universal
make</code>
 
== 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.


== Where's the built viewer? ==
== Where's the built viewer? ==


On OS X, your viewer build will be in "build-darwin-''platform''/newview/RelWithDebInfo/Snowglobe.app" or "build-darwin-''platform''/newview/RelWithDebInfo/Second Life.app" depending on which branch you built.
On OS X, your viewer build will be in "build-darwin-i386/newview/RelWithDebInfo/Second Life.app" depending on which branch you built.


The easiest way to launch your compiled viewer is to simply navigate under the Finder to that folder and double click the application.
The easiest way to launch your compiled viewer is to simply navigate under the Finder to that folder and double click the application.
Line 116: Line 38:
Note:
Note:
* If you change the build configuration you use, the intermediate directory will also change, e.g. from <code>RelWithDebInfo</code> to <code>Release</code>.
* If you change the build configuration you use, the intermediate directory will also change, e.g. from <code>RelWithDebInfo</code> to <code>Release</code>.
* Depending on your platform, the ''platform'' will be chosen among ''i386'', ''PPC'' and ''universal''.


= Building the Unit Tests =
= Building the Unit Tests =
Line 123: Line 44:
= What to do if it doesn't work for you =
= What to do if it doesn't work for you =


* Check your environment. Ensure you have the OS X 10.6 (NOTE: see [http://jira.secondlife.com/browse/SNOW-223]) 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 about "vivox" or "fmod" missing, you skipped the fmod step or installed fmod after running develop.py. In that case, you need to delete "linden/indra/build-darwin-platform" and rebuild it using develop.py
* 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 from 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 [[IRC]] (irc.freenode.net #opensl)
* Ask for help on the [[SLDev|Opensource-dev mailing list]]
* Ask for help on the [[SLDev|Opensource-dev mailing list]]

Revision as of 10:50, 28 March 2011

For recent information check the Project Snowstorm page.

Getting Development Tools

  • Xcode: Most Lindens use Xcode 3.2 on Snow Leopard (OS X 10.6) for building on Macintosh computers. For simplicity, we suggest installing everything from the mpkg. Note that later versions of Xcode have build options to be backwards compatible to 3.1. (See Talk:Compiling_the_viewer_(Mac_OS_X)#Trying_newer_versions_of_tools. Later versions of Xcode (3.2.4) work fine.)
  • CMake: Install CMake from cmake.org, or using MacPorts with 'port install cmake'. You will need at least CMake 2.6; CMake 2.8 may be required in the future.
  • Command line Makefiles: These are included in Apple's Xcode product. Download and install Xcode from Apple.

Downloading Source Code

Linden Lab Project Snowstorm uses Mercurial and Bit Bucket for the version control repository. The repository is here. Look vor viewer-development, viewer-beta, viewer-release, and others, as your needs dictate. If you're just starting out, it's probably best to get viewer-release or viewer-beta , because viewer-developer gets updated several times per week. But if you would rather work with the latest code, look for the latest builds on Project Snowstorm and viewer-developer on bitbucket.


Installing Proprietary Libraries

Some builds of the the Viewer depends on proprietary libraries (alternative open source libraries are also provided for developers who prefer or are not licensed to use the 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

(instructions needed)

Build the viewer with autobuild

Configuring and building with autobuild works the same on all platforms. Full instructions may be found at Build_Viewer_With_Autobuild.

Xcode

If you have followed the configure instructions from Build_Viewer_With_Autobuild, the directory build-darwin-i386 will have been created in the root of your source distribution. Inside that directory you will find the SecondLife.xcodeproj project file which can be used with Xcode. When opened it should be configured correctly to build, so just Build and Run.

Where's the built viewer?

On OS X, your viewer build will be in "build-darwin-i386/newview/RelWithDebInfo/Second Life.app" depending on which branch you built.

The easiest way to launch your compiled viewer is to simply navigate under the Finder to that folder and double click the application.

Note:

  • If you change the build configuration 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

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.