Build the Viewer on Linux: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
→‎Prerequisites: added "missing vital information"-Template about llmozlib
Leviathan Linden (talk | contribs)
Update requirements list.
 
(380 intermediate revisions by 54 users not shown)
Line 1: Line 1:
{{Multi-lang}}
{{CompileNav}}
{{CompileNav}}
{{TOC}}


The following are instructions for building the Second Life viewer on linux. This process has only been used on [http://www.debian.org/ debian] and debian based systems like [http://www.ubuntu.com/ ubuntu]. For other platforms, see [[Get source and compile]].
==Step 0. Review BUILD.LINUX.md==
There is a [https://github.com/secondlife/viewer/blob/develop-linux/doc/BUILD.LINUX.md BUILD.LINUX.md] markdown file in the active '''develop-linux''' branch (see '''Step 2''') which will eventually become the primary documentation for building the SL viewer on Linux. In the meantime the instructions below may also be helpful.


== Installing the required dependencies ==
==Step 1. Install Requirements==


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 <i>slviewer-linux-libs</i> 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.
* Python 3.7+
* [https://git-scm.com/downloads Git]
* [https://cmake.org/download/ CMake] 3.20+ (need to be able to handle <code>--config</code> option)
* Native packages and tools (this list may be incomplete, please update as new dependencies are discovered):
  libfontconfig-dev libglib2.0-dev libglvnd-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libosmesa6-dev libvlc-dev libwayland-dev libx11-dev ninja-build python3-venv
* [[Autobuild]] (probably best installed in a [https://docs.python.org/3/library/venv.html virtual environment])


Paths and package names given here are based on Ubuntu 6.06 and may vary according to your Linux distribution.
===Intermediate Check===


=== Prerequisites ===
Confirm things are installed properly so far by typing the following in a terminal:
{{vital-info|How to compile [[Source_archive#2007-Feb-20|FL-1.13.3.58185]] and [[Source_archive#2007-Feb-24|FL-1.13.3.58390]] '''with''' and/or '''without''' llmozlib (see [[Talk:Compiling_the_viewer_%28Linux%29#llmozlib|discussion]])}}
cmake --version
* You will need the <b>SCons</b> build tool [package: scons]
python3 --version
* You should use the <b>GCC 3.4</b> 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.
git --version
autobuild --version


* fetch and unpack <b>FMOD 3.75</b> <http://www.fmod.org/>
If everything reported sensible values and not "Command not found" errors, then you are in good shape!
** FMOD provides audio output, but (although 'free' in some senses) is not itself open-source.  <b>If</b> you wish to avoid FMOD, thus disabling audio, you may make these changes:
*** Remove the reference to '<b>fmod-3.75</b>' in indra/SConstruct
*** Replace '<b>-DLL_SDL=1</b>' with '<b>-DLL_SDL=1 -DLL_FMOD=0</b>' in indra/SConstruct
*** Comment-out the libfmod line in indra/newview/linux_tools/client-manifest-i686


* You will need the <b>Curl</b> library [package: libcurl-dev] - at least version 7.15.4 is recommended, 7.16.x is ideal.
==Step 2. Checkout Code==
** If you are compiling your own version of <b>Curl</b>, then you should consider configuring it to use the <b>c-ares</b> 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]
===Viewer===


* You will need <b>GTK 2.x development headers</b> [libgtk2.0-dev]
Open a terminal and checkout the viewer source code:
git clone https://github.com/secondlife/viewer.git


* You will need <b>yacc</b> and <b>lex</b> [suggest packages: bison, flex]
Until it is merged into the '''develop''' branch you need to checkout '''develop-linux''':
cd viewer
git checkout develop-linux


* You may <b>either</b> use our easy <i>slviewer-linux-libs</i> bundle of pre-built libraries and headers unpacked into the Second Life Viewer source tree, <b>or</b> (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:
===Build Variables===
** <b>boost</b> [libboost-dev]
** <b>boost-regex</b> [libboost-regex-dev]
** <b>apr-1</b> [libapr1.0-dev]
** <b>aprutil-1</b> [libaprutil1.0-dev]
** <b>xmlrpc-epi 0.51</b> <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  --[[User:Caelum Lewellen|Caelum Lewellen]] 15:47, 11 January 2007 (PST)
** <b>jpeglib</b> [libjpeg62-dev]
** <b>SDL</b> [libsdl1.2-dev]
** <b>Vorbis</b> [libvorbis-dev]
** build <b>ELFIO</b> <http://sourceforge.net/projects/elfio/>
*** This wants to build a static library by default.  Afterwards, to create a dynamic libelfio.so: <code>cd ELFIO && g++-3.4 -shared *.o -o libelfio.so</code>
** build <b>OpenJPEG</b> <http://www.openjpeg.org/>
*** note: OpenJPEG greater than 1.1 is required which hash the macro OPJ_PATH_LEN.  Version 1.1 and before would crash with a divide by zero with Second Life.  Get the source with svn until 1.2 comes out.
*** 02-15-2007, another set of patches is required to both OpenJPEG and Second Life to make it usable, that is fix a crash, make it look good, and speed it up.  https://jira.secondlife.com:443/browse/VWR-123
** <b>expat</b> [libexpat1-dev]


=== Copy headers and libraries into the source tree ===
See [[Building the Viewer with Autobuild#Select Build Variables]]


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.
==Step 3. Configure==
* ${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.
<code>
cp ${FMOD}/api/inc/* ${SLSRC}/libraries/i686-linux/include/
cp ${FMOD}/api/libfmod-3.75.so ${SLSRC}/libraries/i686-linux/lib_release_client/


cp -a /usr/include/atk-1.0 ${SLSRC}/libraries/i686-linux/include/
Be sure you have the following environment variables set before continuing:
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:
AUTOBUILD_ADDRSIZE=64
  cp -a /usr/include/cairo/* ${SLSRC}/libraries/i686-linux/include/
  AUTOBUILD_VARIABLES_FILE=<path to autobuild viewer variables>


</code>
Configuring and building with '''autobuild''' works the same on all platforms.  Full instructions may be found at [[Build_Viewer_With_Autobuild]].


If you are using our easy <i>slviewer-linux-libs</i> bundle then you can skip the rest of this section, <b>otherwise</b> you will also need to perform the following:
  autobuild configure -c RelWithDebInfoOS
* ${OPENJPEG} refers to the top-level directory of your completed OpenJPEG build.
* ${ELFIO} refers to the top-level directory of your completed ELFIO build.
<code>
  cp -a /usr/include/apr-1.0/ ${SLSRC}/libraries/i686-linux/include/apr-1


mkdir ${SLSRC}/libraries/i686-linux/include/expat
==Step 4. Build==
cp -a /usr/include/expat*.h ${SLSRC}/libraries/i686-linux/include/expat/


  mkdir ${SLSRC}/libraries/i686-linux/include/zlib
  autobuild build
cp -a /usr/include/zlib*.h ${SLSRC}/libraries/i686-linux/include/zlib/


mkdir ${SLSRC}/libraries/i686-linux/include/openjpeg
===Running your newly built viewer===
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
==Step 5. Run==
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
To launch the '''viewer''' you built, from your source tree root directory, run:
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
  build-linux-x86_64/newview/packaged/secondlife
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/
</code>


== Compiling ==
==Step 6. Optional==


<code>
===Running Unit Tests===
$ cd indra
$ scons DISTCC=no BTARGET=client BUILD=release
</code>
Expect a build time of a couple of hours.  The resulting unstripped Second Life Viewer binary is <b>newview/secondlife-i686-bin</b>. Note that temporary object code is compiled into <b>/tmp/$USER</b> by default (where $USER is your username) - this can be changed by prefixing the <b>scons</b> command above with <b>TEMP_BUILD_DIR="<i>[full directory path]</i>"</b>. For example:


<code>
TODO: provide instructions for running unit tests.
$ TEMP_BUILD_DIR="/home/fred/secondlife/temp-build" scons DISTCC=no BTARGET=client BUILD=release
</code>


To build a release that has all of the shaders and optimizations enabled and resembles the official shipped Linux alpha client, use BUILD=releasefordownload
===Optional: Installing Proprietary Libraries===


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.
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.)


== Testing and packaging the client ==
TODO: provide instructions for building proprietary libraries.


=== Testing the result from inside the tree ===
==Handling Problems==


You may find it simpler 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:
If you encounter errors or run into problems following the instructions above, please first check whether someone else already had the same issue. A solution might be known already.


* Preparing to run 'in-tree'
You may find the solution in any of these resources:
** <i>ensure that you have indra/newview/app_settings/static_*.db2</i> - if not, you'll find it in the 'slviewer-artwork' download (a zip file).
* [[{{TALKPAGENAME}}|This talk page]] (Report useful experiences there)
** now, from the indra directory:
* [[#Common_Issues.2FBugs.2FGlitches_And_Solutions|Issue list below]] (If new issues, please add it to talk page above instead of there)
<code>
* [[Talk:Microsoft_Windows_Builds|Old talk page]]
$ cp ../scripts/messages/message_template.msg newview/app_settings/
* [[Common compilation problems]] (Rather old)
</code>
* [[Issue tracker]]


* Running it: The LD_LIBRARY_PATH stuff ensures that the binary looks for its libraries in the right places.  From the indra directory:
* Fix it: [[Modifying CMake Files‎]] and please, submit a patch!
<code>
$ ( cd newview && LD_LIBRARY_PATH=../../libraries/i686-linux/lib_release_client:${LD_LIBRARY_PATH}:/usr/local/lib  ./secondlife-i686-bin )
</code>


** For version '''20070117a''' the binary name seems to have changed to '''secondlife-i686-bin-globalsyms''', so the command would be
===Getting Help===
<code>
$ ( cd newview && LD_LIBRARY_PATH=../../libraries/i686-linux/lib_release_client:${LD_LIBRARY_PATH}:/usr/local/lib  ./secondlife-i686-bin-globalsyms )
</code>


==== Augh!!  The client seems REALLY slow!! ====
Even when no description of your problem has been written down yet, someone might know about it, so get in touch with the community to get help.


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.
* Subscribe to [[OpenSource-Dev|OpenSource-Dev Mailing List]] ([https://lists.secondlife.com/cgi-bin/mailman/listinfo/opensource-dev subscribe]) and post your question there.


However, the <i>slviewer-linux-libs</i> package includes two pre-built libraries which facilitate the use of this smoother image decoding method: <b>libkdu_v42R.so</b> and <b>libllkdu.so</b>.  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.
----
 
[[Category:Compiling viewer]]
To <b>use these faster image-decoding libraries</b>, 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:
<code>
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"
</code>
 
The file <b>indra/newview/linux_tools/client-manifest-i686</b> 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 '<b>BUILD=releasefordownload</b>' 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 <b>indra/newview/SecondLife_i686_1_X_Y_Z/</b> and has also been tarred into <b>indra/newview/SecondLife_i686_1_X_Y_Z.tar.bz2</b>
 
The file which controls what (and where) files go into the end-user runtime viewer directory is <b>indra/newview/linux_tools/client-manifest-i686</b>
 
==== Packaging errors ====
 
The final packaging step may fail with errors about the manifest if you are not using the <i>slviewer-linux-libs</i> 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 <b>indra/newview/linux_tools/client-manifest-i686</b>
 
==== FreeBSD ====
 
A list of patches is given for [[Compiling the viewer FreeBSD]].

Latest revision as of 09:37, 5 January 2026

Step 0. Review BUILD.LINUX.md

There is a BUILD.LINUX.md markdown file in the active develop-linux branch (see Step 2) which will eventually become the primary documentation for building the SL viewer on Linux. In the meantime the instructions below may also be helpful.

Step 1. Install Requirements

  • Python 3.7+
  • Git
  • CMake 3.20+ (need to be able to handle --config option)
  • Native packages and tools (this list may be incomplete, please update as new dependencies are discovered):
 libfontconfig-dev libglib2.0-dev libglvnd-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libosmesa6-dev libvlc-dev libwayland-dev libx11-dev ninja-build python3-venv

Intermediate Check

Confirm things are installed properly so far by typing the following in a terminal:

cmake --version
python3 --version
git --version
autobuild --version

If everything reported sensible values and not "Command not found" errors, then you are in good shape!

Step 2. Checkout Code

Viewer

Open a terminal and checkout the viewer source code:

git clone https://github.com/secondlife/viewer.git

Until it is merged into the develop branch you need to checkout develop-linux:

cd viewer
git checkout develop-linux

Build Variables

See Building the Viewer with Autobuild#Select Build Variables

Step 3. Configure

Be sure you have the following environment variables set before continuing:

AUTOBUILD_ADDRSIZE=64
AUTOBUILD_VARIABLES_FILE=<path to autobuild viewer variables>

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

autobuild configure -c RelWithDebInfoOS

Step 4. Build

autobuild build

Running your newly built viewer

Step 5. Run

To launch the viewer you built, from your source tree root directory, run:

 build-linux-x86_64/newview/packaged/secondlife

Step 6. Optional

Running Unit Tests

TODO: provide instructions for running unit tests.

Optional: 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.)

TODO: provide instructions for building proprietary libraries.

Handling Problems

If you encounter errors or run into problems following the instructions above, please first check whether someone else already had the same issue. A solution might be known already.

You may find the solution in any of these resources:

Getting Help

Even when no description of your problem has been written down yet, someone might know about it, so get in touch with the community to get help.