Build the Viewer on Linux
The following are instructions for building the Second Life viewer on linux. This process has only been used on debian and debian based systems like ubuntu. For other platforms, see Get source and compile.
Installing the required dependencies
The Second Life Viewer has a number of compile/link dependencies on external libraries which need to be put in place first - to help you, the source download page contains a link to a slviewer-linux-libs package which you unpack over the source tree to fill most of the dependancies (and thus avoid most of the fiddly work described on this page). The Second Life Viewer is not a trivial build, and experience with building large software packages will help you greatly - but don't be daunted, it should be simple once the dependencies are in the right place the first time.
Paths and package names given here are based on Ubuntu 6.06 and may vary according to your Linux distribution.
- If you download the art and libs to the top folder, where the linden folder is after getting the veiwer source code, the following commands should unpack everything to the right spot.
unzip slviewer-artwork-<version>.zip
tar xvfz slviewer-linux-libs-<version>.tar.gz
Prerequisites
- You will need the SCons build tool [package: scons]
- You should use the GCC 3.4 C/C++ compiler [package: g++-3.4]; other GCC versions are not well-tested; GCC 4.x will NOT currently build the viewer without some code adjustments.
- fetch and unpack FMOD 3.75 <http://www.fmod.org/>
- FMOD provides audio output, but (although 'free' in some senses) is not itself open-source. If you wish to avoid FMOD, thus disabling audio, you may make these changes:
- Remove the reference to 'fmod-3.75' in indra/SConstruct
- Replace '-DLL_SDL=1' with '-DLL_SDL=1 -DLL_FMOD=0' in indra/SConstruct
- Comment-out the libfmod line in indra/newview/linux_tools/client-manifest-i686
- FMOD provides audio output, but (although 'free' in some senses) is not itself open-source. If you wish to avoid FMOD, thus disabling audio, you may make these changes:
- If you want to use FMOD:
wget http://www.fmod.org/files/fmodapi375linux.tar.gz
tar -xzvf fmodapi375linux.tar.gz
cd fmodapi375linux/
cp api/inc/* ../linden/libraries/i686-linux/include/
cp api/libfmod-3.75.so ../linden/libraries/i686-linux/lib_release_client/
- You will need the Curl library [package: libcurl-dev] - at least version 7.15.4 is recommended, 7.16.x is ideal.
- If you are compiling your own version of Curl, then you should consider configuring it to use the c-ares library so that DNS lookups will be asynchronous.
- You will need some development headers for OpenGL and X11: gl.h, glext.h, glu.h, Xlib.h, and Xutil.h [packages: mesa-common-dev, libglu1-mesa-dev, libx11-dev]
- You will need GTK 2.x development headers [libgtk2.0-dev]
- You will need yacc and lex [suggest packages: bison, flex]
- You may either use our easy slviewer-linux-libs bundle of pre-built libraries and headers unpacked into the Second Life Viewer source tree, or (for example if you are porting to a new architecture or wish to make a package tailored to your Linux distribution's own libraries) you will have to install the following additional dependencies:
- boost [libboost-dev]
- boost-regex [libboost-regex-dev]
- apr-1 [libapr1.0-dev]
- aprutil-1 [libaprutil1.0-dev]
- xmlrpc-epi 0.51 <http://xmlrpc-epi.sourceforge.net/>
- note: not xmlrpc-c (xmlrpc-c has a library and headers with the same name but is not compatible)
- Apply patches from the instructions in patch xmlrpc-epi.
- Build with ./configure --prefix=/usr --includedir=/usr/include/xmlrpc-epi --Caelum Lewellen 15:47, 11 January 2007 (PST)
- jpeglib [libjpeg62-dev]
- SDL [libsdl1.2-dev]
- Vorbis [libvorbis-dev]
- build ELFIO <http://sourceforge.net/projects/elfio/>
- This wants to build a static library by default. Afterwards, to create a dynamic libelfio.so:
cd ELFIO && g++-3.4 -shared *.o -o libelfio.so
- This wants to build a static library by default. Afterwards, to create a dynamic libelfio.so:
- build OpenJPEG <http://www.openjpeg.org/>
- note: OpenJPEG 1.1.1 or greater is required which has the macro OPJ_PATH_LEN, if the header has MAX_PATH, then upgrade or it will crash with a divide by zero error as the structures would be two different sizes.
- 02-26-2007, another set of patches is required to Second Life to make it usable, that is fix a crash, make it look good, and speed it up. See https://jira.secondlife.com:443/browse/VWR-123
- expat [libexpat1-dev]
Copy headers and libraries into the source tree
Here is a guide to the sequence of shell commands needed to copy the required headers and libraries into the Second Life Viewer source tree for building. Actual paths to system headers may vary according to Linux distribution.
- ${SLSRC} refers to the top-level directory of the Second Life Viewer source tree.
- ${FMOD} refers to the top-level directory into which you unpacked FMOD 3.
cp ${FMOD}/api/inc/* ${SLSRC}/libraries/i686-linux/include/
cp ${FMOD}/api/libfmod-3.75.so ${SLSRC}/libraries/i686-linux/lib_release_client/
You only need to copy the following if you're not using the handy slviewer-linux-libs package:
cp -a /usr/include/atk-1.0 ${SLSRC}/libraries/i686-linux/include/
cp -a /usr/include/gtk-2.0 ${SLSRC}/libraries/i686-linux/include/
cp -a /usr/lib/gtk-2.0/include/* ${SLSRC}/libraries/i686-linux/include/gtk-2.0/
cp -a /usr/include/glib-2.0 ${SLSRC}/libraries/i686-linux/include/
cp -a /usr/lib/glib-2.0/include/* ${SLSRC}/libraries/i686-linux/include/glib-2.0/
cp -a /usr/include/pango-1.0 ${SLSRC}/libraries/i686-linux/include/
if your GTK is fairly recent and thus needs Cairo:
cp -a /usr/include/cairo/* ${SLSRC}/libraries/i686-linux/include/
Fix Shell Scripts
Some systems don't use bash for /bin/sh. Ubuntu is one example. If this is the case on your system, you must do the following, since these scripts are actually bash scripts, but call /bin/sh.
Edit the first line of these scripts, changing #!/bin/sh to #!/bin/bash
- linden/indra/newview/linux_tools/launch_url.sh
- linden/indra/newview/linux_tools/wrapper.sh
- linden/indra/newview/linux_tools/package-client.sh
- (looks like this file doesn't exist anymore)
- linden/libraries/include/boost/pool/detail/pool_construct_simple.sh
- linden/libraries/include/boost/pool/detail/pool_construct.sh
- linden/libraries/i686-linux/include/apr-1/arch/unix/apr_arch_threadproc.h
- (it's at line 47 - 1.15.0.2 release)
Disable llMozLib
Add MOZLIB=no to your Scons build command when compiling the source.
Libs
If you are using our easy slviewer-linux-libs bundle then you can skip the rest of this section, otherwise you will also need to perform the following:
- ${OPENJPEG} refers to the top-level directory of your completed OpenJPEG build.
- ${ELFIO} refers to the top-level directory of your completed ELFIO build.
cp -a /usr/include/apr-1.0/ ${SLSRC}/libraries/i686-linux/include/apr-1
mkdir ${SLSRC}/libraries/i686-linux/include/expat
cp -a /usr/include/expat*.h ${SLSRC}/libraries/i686-linux/include/expat/
mkdir ${SLSRC}/libraries/i686-linux/include/zlib
cp -a /usr/include/zlib*.h ${SLSRC}/libraries/i686-linux/include/zlib/
mkdir ${SLSRC}/libraries/i686-linux/include/openjpeg
cp ${OPENJPEG}/libopenjpeg/openjpeg.h ${SLSRC}/libraries/i686-linux/include/openjpeg/
cp ${OPENJPEG}/libopenjpeg.a ${SLSRC}/libraries/i686-linux/lib_release_client/
mkdir ${SLSRC}/libraries/i686-linux/include/ELFIO
cp ${ELFIO}/ELFIO/*.h ${SLSRC}/libraries/i686-linux/include/ELFIO/
cp ${ELFIO}/ELFIO/libelfio.so ${SLSRC}/libraries/i686-linux/lib_release_client/
mkdir ${SLSRC}/libraries/i686-linux/include/jpeglib
cp -a /usr/include/j*.h ${SLSRC}/libraries/i686-linux/include/jpeglib/
touch ${SLSRC}/libraries/i686-linux/include/jpeglib/jinclude.h
mkdir ${SLSRC}/libraries/i686-linux/include/llfreetype2
cp -a /usr/include/freetype2/freetype/ ${SLSRC}/libraries/i686-linux/include/llfreetype2/
cp -a /usr/include/ft2build.h ${SLSRC}/libraries/i686-linux/include/llfreetype2/freetype/
Compiling
$ cd indra
$ scons DISTCC=no BTARGET=client BUILD=release MOZLIB=no
Expect a build time of a couple of hours. The resulting unstripped Second Life Viewer binary is newview/secondlife-i686-bin. Note that temporary object code is compiled into /tmp/$USER by default (where $USER is your username) - this can be changed by prefixing the scons command above with TEMP_BUILD_DIR="[full directory path]". For example:
$ TEMP_BUILD_DIR="/home/fred/secondlife/temp-build" scons DISTCC=no BTARGET=client BUILD=release
To build a release that has all of the shaders and optimizations enabled and resembles the official shipped Linux alpha client, use BUILD=releasefordownload
Be sure to read the Common compilation problems page if you have problems - we'll try to keep the page up to date with known problems and solutions.
Testing and packaging the client
Testing the result from inside the tree
You may find it simpler and less error-prone to follow the instructions in the 'Packaging the client' section below to run the client under the same conditions as an end-user would. Otherwise:
- Preparing to run 'in-tree'
- ensure that you have indra/newview/app_settings/static_*.db2 - if not, you'll find it in the 'slviewer-artwork' download (a zip file).
- now, from the indra directory:
$ cp ../scripts/messages/message_template.msg newview/app_settings/
- Running it: The LD_LIBRARY_PATH stuff ensures that the binary looks for its libraries in the right places. From the indra directory:
$ ( cd newview && LD_LIBRARY_PATH=../../libraries/i686-linux/lib_release_client:${LD_LIBRARY_PATH}:/usr/local/lib ./secondlife-i686-bin )
- For version 20070117a the binary name seems to have changed to secondlife-i686-bin-globalsyms, so the command would be (Tofu Linden says - this was an oversight after a build process change, and future releases will generate a secondlife-i686 again, whereupon this instruction can be removed. :))
$ ( cd newview && LD_LIBRARY_PATH=../../libraries/i686-linux/lib_release_client:${LD_LIBRARY_PATH}:/usr/local/lib ./secondlife-i686-bin-globalsyms )
Augh!! The client seems REALLY slow!!
By default, the open-source Second Life Viewer uses the open-source OpenJPEG library to decode the (many) JPEG-2000 texture images it receives from the servers. Unfortunately this isn't quite of comparable speed to the proprietary third-party library which the Linden Lab viewer builds have traditionally used, for which we are not permitted to redistribute the source.
However, the slviewer-linux-libs package includes two pre-built libraries which facilitate the use of this smoother image decoding method: libkdu_v42R.so and libllkdu.so. These are provided for your testing; again, we are not permitted to grant you the right to re-distribute these libraries to downstream users, but the viewer will still work (albeit slower) without them.
To use these faster image-decoding libraries, they simply need to be put into the right places relative to the viewer runtime directory - nothing needs to be reconfigured or recompiled. If you're running the client from the source tree, the following will make the KDU libraries available:
cp "$SLSRC/libraries/i686-linux/lib_release_client/libllkdu.so" "$SLSRC/indra/newview/libllkdu.so"
mkdir "$SLSRC/indra/lib"
cp "$SLSRC/libraries/i686-linux/lib_release_client/libkdu_v42R.so" "$SLSRC/indra/lib/libkdu_v42R.so"
The file indra/newview/linux_tools/client-manifest-i686 contains some commented-out entries describing where these libraries belong; if you uncomment the two lines corresponding to libllkdu and libkdu then they will be automatically copied into the right place in the runtime directory when you follow the 'Packaging the client' instructions below.
"Unable to initialize communications"
If the viewer just displays the error message " Unable to initialize communications" and exits, it can't find message_template.msg. You did remember to copy it over, right?
Packaging the client
If you substitute 'BUILD=release' with 'BUILD=releasefordownload' in the 'Compiling' section above, then packaging the resulting code, libraries, data and documentation into a tarball for the end-user will be done automatically as the final stage of the build process; the pristine end-user client distribution has been assembled into the directory indra/newview/SecondLife_i686_1_X_Y_Z/ and has also been tarred into indra/newview/SecondLife_i686_1_X_Y_Z.tar.bz2
The file which controls what (and where) files go into the end-user runtime viewer directory is indra/newview/linux_tools/client-manifest-i686
Packaging errors
The final packaging step may fail with errors about the manifest if you are not using the slviewer-linux-libs bundle; in this case, if you still wish to end up with an end-user viewer package incorporating your own libraries, you can edit the manifest file found at indra/newview/linux_tools/client-manifest-i686
FreeBSD
A list of patches is given for Compiling the viewer (FreeBSD).