Compiling the viewer (MSVS2003)

From Second Life Wiki
Jump to navigation Jump to search

The following instructions are for compiling the Second Life viewer on Windows. For other platforms, see Compiling the viewer. If you get lost, or these instructions are incomplete, email ben@lindenlab.com - I'll try to get them fixed.

Windows

Development Environment

The following dev environment is what LL uses for Windows development. There is no reason that the Second Life viewer can not be built using other environments, but it will take some extra work. We should soon have instructions for building the viewer using Microsoft's Visual Studio .NET 2005 Express, which at the time of writing, was freely available.

  • Visual Studio .NET 2003 Professional
    • Microsoft Platform SDK
    • NEED NEWER DIRECTX DirectX 9.0 SDK Update (Summer 2003)
    • Set up the project globals:
      • Start Visual C++
      • Go to Tools/Options/Projects/VC++ Directories
      • Make sure that the includes and libraries paths have the DirectX SDK paths first, then the Platform SDK paths, and then the Visual C++ paths.
  • ActivePython 2.3x
  • ActivePerl
  • Cygwin
    • When you run the cygwin setup utility make sure you have selected to install patchutil, flex, and bison (all located under "devel").

Libraries

If you have downloaded the library directory from LL, extract it, and copy the files to your code directory, maintaining the same directory structure. We have included all the libraries we can ship in this file, but we can not distribute the source to the following , and you will need to follow the instructions to acquire below:

Fmod Quicktime

In the source directory, there are several empty placeholder folders for libraries which the Second Life viewer relies upon. This section describes how to acquire the code, and how to install it. It is a good idea to install in order, as some libraries will rely on previous installs (ie, libcurl needs opensll and zlib).

Boost
  • Download & extract Boost source for win32.
  • Copy the "boost_X_XX_X\boost" folder to "libraries\include\".
  • Run "boost_X_XX_X\tools\build\jam_src\build".
  • Copy "boost_X_XX_X\tools\build\jam_src\bin.ntx86\bjam.exe" to "boost_X_XX_X\".
  • Using the command prompt, build the static libraries:
    • cd linden\libraries\boost-X_XX_X\
    • set PYTHON_ROOT=C:\Python23
    • set PYTHON_VERSION=2.3
    • bjam stage
  • copy "boost_X_XX_X\stage\lib\libboost_python-vc71-mt.lib" to "\libraries\i686-win32\lib_release\"
  • copy "boost_X_XX_X\stage\lib\libboost_python-vc71-mt-gd.lib" to "\libraries\i686-win32\lib_release\libboost_python-vc71-mt.lib"
  • copy "boost_X_XX_X\stage\lib\libboost_regex-vc71-mt-s.lib" to "\libraries\i686-win32\lib_release\"
  • copy "boost_X_XX_X\stage\lib\libboost_regex-vc71-mt-sgd.lib" to "\libraries\i686-win32\lib_release\libboost_regex-vc71-mt-s.lib"
Expat
  • Download and run Expat Win32 Binary
  • copy "Expat-X.X.X\Source\lib\expat.h" to "libraries\include\expat\".
  • copy "Expat-X.X.X\Source\lib\expat_external.h" to "libraries\include\expat\".
  • copy "Expat-X.X.X\StaticLibs\libexpatMT.lib" to "libraries\i686-win32\lib_release\".
  • copy "Expat-X.X.X\StaticLibs\libexpatMT.lib" to "libraries\i686-win32\lib_debug\".
ZLib
  • Download & extract Zlib
  • copy "zlibXXX\zlib.h" to "libraries\include\zlib\".
  • copy "zlibXXX\zconf.h" to "libraries\include\zlib\".
  • Using the command prompt, build the static libraries:
    • "C:\Program Files\Microsoft Visual Studio .net 2003\Common7\Tools\vsvars32.bat"
    • cd %ZLIB_FOLDER%
    • nmake -f win32/Makefile.msc
  • copy "zlibXXX\zlib.lib" to "libraries\i686-win32\lib_release\".
  • copy "zlibXXX\zlib.lib" to "libraries\i686-win32\lib_debug\".
Apache Portable Runtime
  • Take out XML dependancies, move expat headers!!!!
  • Download & extract apr, apr-util, and apr-iconv.
  • For simplicity place all three in a parallel directory structure, and rename the directories:
    • C:\work\apr\
    • C:\work\apr-iconv\
    • C:\work\apr-util\
  • Open the "\apr-util\aprutil.dsp" project in VS2003.
  • For the apr, apr-util & aper-iconv projects, change the Runtime Library from Multi-threaded DLL to Multi-threaded:
    • Right click each project in the Solution Explorer, choose properties.
    • In the C/C++ folder, choose Code Generation.
    • Change the Runtime Library to Muli-threaded.
    • Repeat for both debug and release.
  • Remove the apr-util's dependency on xml:
    • Right click the apr-util project, and choose dependencies.
    • Uncheck xml.
    • Right click the xml project in the Solution Explorer.
    • Choose Remove.
  • copy "Expat-X.X.X\Source\lib\expat.h" to "apr\apr-util\xml".
  • copy "Expat-X.X.X\Source\lib\expat_external.h" to "apr\apr-util\xml\".
  • Build Solution for Debug, and build solution for release.
  • copy "\apr-util\LibR\aprutil-1.lib" to "libraries\i686-win32\lib_release".
  • copy "\apr-util\LibR\aprutil_src.pdb" to "libraries\i686-win32\lib_release".
  • copy "\apr\LibR\apr-1.lib" to "libraries\i686-win32\lib_release".
  • copy "\apr\LibR\apr_src.pdb" to "libraries\i686-win32\lib_release".
  • copy "\apr-util\LibD\aprutil-1.lib" to "libraries\i686-win32\lib_debug".
  • copy "\apr-util\LibD\aprutil_src.pdb" to "libraries\i686-win32\lib_debug".
  • copy "\apr\LibD\apr-1.lib" to "libraries\i686-win32\lib_debug".
  • copy "\apr\LibD\apr_src.pdb" to "libraries\i686-win32\lib_debug".
  • copy header files:
    • copy the contents of "apr\include" to "libraries\i686-win32\include\apr-1".
    • in "libraries\i686-win32\include\apr-1\arch\" only the "win32" dir and "apr_private_common.h" are required.
    • copy the contents of "apr-util\include" to "libraries\i686-win32\include\apr-1".
Freetype
  • Download and run FreeType for Windows.
  • copy the contents of "GnuWin32\include\freetype2\freetype" into "\libraries\include\freetype"
  • copy "GnuWin32\libfreetype.lib" to "libraries\i686-win32\lib_release".
  • copy "GnuWin32\libfreetype.lib" to "libraries\i686-win32\lib_debug".
  • copy "GnuWin32\include\ft2build.h" to "libraries\include".
gl
OpenSSL
  • Download and extract
  • Using the command prompt, build the static libraries:
    • cd %PATH%
    • perl Configure VC-WIN32
    • ms\do_masm
  • Edit openssl-X.X.Xy\ms\nt.mak
    • Change /MD to /MT in CFLAGS
  • back in the command prompt:
    • nmake -f ms\nt.mak
    • copy all the ".lib" files from "openssl-X.X.Xy\out32" to "libraries\i686-win32\lib_release"
cURL
  • Download & extract the curl source.
  • Edit "curl-X.XX.X\lib\Makefile.vc6"
    • Change OPENSSL_PATH to ../../../openssl-<version>
    • Change the ZLIB_PATH to ../../../zlib-<version>/src
    • Change RTLIB to /MT
    • Change RTLIBD to /MTd
  • Using the command prompt, build the static libraries:
    • "C:\Program Files\Microsoft Visual Studio .net 2003\Common7\Tools\vsvars32.bat"
    • cd %PATH%\lib\
    • nmake /f Makefile.vc6 CFG=release-ssl-zlib
    • Copy "curl-X.XX.X\lib\release-ssl-zlib\libcurl.lib" to "libraries\i686-win32\lib_debug"
    • Copy "curl-X.XX.X\lib\release-ssl-zlib\libcurl.lib" to "libraries\i686-win32\lib_release"
    • Copy all the header files in "curl-X.XX.X\include\curl" to "libraries\include\curl"
XMLRPC-epi
  • Using cygwin:
$ tar xvzf xmlrpc-epi-0.51
$ cd xmlrpc-epi-0.51
$ patch -p1 < ../remove_iconv.patch
$ patch -p1 < ../excise_expat.patch
$ rm -rf expat
$ mkdir expat
$ cp $FOO expat
    Where $FOO is either
        /tmp/expat/include/* -- if you built expat recently
    or  ../../expat-1.95.8/src/lib/expat*.h -- if you haven't
    in this later case you'll need to have CVS gotten the expat
    lib, and expanded it's src.tar.gz file there
  • Copy over the Visual Studio files:
$ cp ../src/xmlrpcepi.* .
  • Open the xmlrpcepi.sln file and build
Vorbis & Ogg
  • Download & extract libvorbis.
  • Download & extract libogg.
  • Build & copy libogg first:
    • Open "libogg-X.X.X\win32\ogg_static.dsp" in visual studio.
    • Build both debug and release solutions.
    • Copy "libogg-X.X.X\include\ogg" into "libvorbis-X.X.X\include"
    • Copy "libogg-X.X.X\include\ogg\ogg.h" to "libraries\include\ogg"
    • Copy "libogg-X.X.X\include\ogg\os_types.h" to "libraries\include\ogg"
    • Copy "libogg-X.X.X\win32\Static_Release\ogg_static.lib" to "libraries\i686-win32\lib_release"
    • Copy "libogg-X.X.X\win32\Static_Debug\ogg_static_d.lib" to "libraries\i686-win32\lib_debug\ogg_static.lib"
  • Build & copy libvorbis:
    • Build release & debug "libvorbis-X.X.X\win32\vorbis_static.dsp"
    • Build release & debug "libvorbis-X.X.X\win32\vorbisfile_static.dsp"
    • Build release & debug "libvorbis-X.X.X\win32\vorbisenc_static.dsp"
    • copy "libvorbis-X.X.X\include\vorbis\codec.h" to "libraries\include\vorbis"
    • copy "libvorbis-X.X.X\include\vorbis\vorbisfile.h" to "libraries\include\vorbis"
    • copy "libvorbis-X.X.X\include\vorbis\vorbisenc.h" to "libraries\include\vorbis"
    • copy "libvorbis-1.1.2\win32\Vorbis_Static_Release\vorbis_static.lib" to "libraries\i686-win32\lib_release"
    • copy "libvorbis-1.1.2\win32\VorbisEnc_Static_Release\vorbisenc_static.lib" to "libraries\i686-win32\lib_release"
    • copy "libvorbis-1.1.2\win32\VorbisFile_Static_Release\vorbisfile_static.lib" to "libraries\i686-win32\lib_release"
    • copy "libvorbis-1.1.2\win32\Vorbis_Static_Debug\vorbis_static_d.lib" to "libraries\i686-win32\lib_debug\vorbis_static.lib"
    • copy "libvorbis-1.1.2\win32\VorbisEnc_Static_Debug\vorbisenc_static_d.lib" to "libraries\i686-win32\lib_debug\vorbisenc_static.lib"
    • copy "libvorbis-1.1.2\win32\VorbisFile_Static_Debug\vorbisfile_static_d.lib" to "libraries\i686-win32\lib_debug\vorbisfile_static.lib"
JPEGlib
  • Download & extract jpeglib.
  • Copy "jpegsr6\jpeg-6b\makefile.vc" to the file "jpegsr6\jpeg-6b\Makefile"
  • Copy "jpegsr6\jpeg-6b\jconfig.vc" to "jpegsr6\jpeg-6b\jconfig.h"
  • At the command prompt:
    • "C:\Program Files\Microsoft Visual Studio .net 2003\Common7\Tools\vsvars32.bat"
    • cd %ZLIB_FOLDER%
    • nmake -f Makefile
  • copy "jconfig.h", "jerror.h", "jmorecfg.h", "jpeglib.h", and "jinclude.h" from * to "libraries\include\jpeglib"
  • copy "jpegsr6\jpeg-6b\libjpeg.lib" to "libraries\i686-win32\lib_release"
  • copy "jpegsr6\jpeg-6b\libjpeg.lib" to "libraries\i686-win32\lib_debug"
  • Patch jpeglib
Fmod
  • Download & extract fmod 3.75 api for win32.
  • Copy "fmodapi375win\api\inc\fmod.h" to "libraries\include"
  • Copy "fmodapi375win\api\inc\fmod_errors.h" to "libraries\include"
  • Copy "fmodapi375win\api\lib\fmodvc.lib" to "libraries\i686-win32\lib_release"
  • Copy "fmodapi375win\api\lib\fmodvc.lib" to "libraries\i686-win32\lib_debug"
Quicktime
  • Download & install the Quicktime SDK for Windows
  • Copy "QuicktimeSDK\Libraries\QTMLClient.lib" to "\libraries\i686-win32\lib_release".
  • Copy "QuicktimeSDK\Libraries\QTMLClient.lib" to "\libraries\i686-win32\lib_debug".
  • Copy the contents of "QuicktimeSDK\CIncludes" into "\libraries\include\quicktime".
OpenJPEG
  • Download and extract openjpeg for win32.
  • Copy "openjpeg10_win32\openjpeg.h" to ""\libraries\include\openjpeg"
  • Copy "openjpeg10_win32\LibOpenJPEG.lib" to "\libraries\i686-win32\lib_release".
  • Copy "openjpeg10_win32\LibOpenJPEG.lib" to "\libraries\i686-win32\lib_debug".
TUT
  • Download and extract tut
  • Copy "tut.h", "tut_reporter.h", and "tut_restartable.h" to "libraries\include\tut"
LLMozLib

These instructions describe how to build the Windows version of LLMozLib for use within the Second Life client. They have been tested using Microsoft Visual Studio 7.1 - apparently, things do work with other versions of the Microsoft compiler but they have not been tried or tested.

LLMozLib currently uses code from the 1.8.0 branch of the Mozilla codebase - similar to what is used in Firefox 1.5. At some point in the future we will switch to the 1.8.1 branch - the one used to build Firefox 2.0.

The steps required to generate LLMozLib and associated run-time files are:

  • Set up your environment for building the Mozilla source code. (these instructions are specific to the Mozilla branch we are using - building the trunk is different)
http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites_on_the_1.7_and_1.8_Branches
  • Checkout the Mozilla source code from their CVS repository. Let's assume you are using the c:\mozilla directory to build in.
 c:
 cd \
 cvs login (the password is 'anonymous')
 cvs checkout -r FIREFOX_1_5_0_9_RELEASE mozilla/client.mk
 cd c:\mozilla
 make -f client.mk checkout MOZ_CO_PROJECT=xulrunner
Note: the CVS tag will change as Mozilla release updates. Version 1.5.0.9 is current as of writing.
  • Apply a patch which enables certain features that are required for the Second Life client.
The patch can be found in the build_mozilla directory.
Copy the patch into the directory where you are building Mozilla and apply the patch:
patch -p0 < linden_updates.patch
  • Build optimized (release) and debug versions of a XULRunner configuration of the Mozilla codebase.
The build_mozilla directory contains 2 Mozilla configuration files - one for a debug build and one for an optimized build.
Copy both files into the directory where you are building Mozilla and then:
copy .mozconfig.debug .mozconfig
make -f client.mk build
copy .mozconfig.optimized .mozconfig
make -f client.mk build
  • Copy a subset of the header files and libraries you built into the LLMozLib tree
There is a batch file in the LLMozLib directory to help you.
You may need to edit the paths at the top if your Mozilla source directory is different.
copy_products_windows.bat
  • Build LLMozLib using Microsoft Visual Studio 7.1
Open the LLMozLib solution file llmozlib.sln.
Build the Debug and Release configurations in the normal fashion.
  • Copy the LLMozLib files to the Second Life client branch
There is a batch file in the LLMozLib directory to help you.
You may need to edit the paths at the top if your Second Life client directory is different.
copy_llmozlib_to_branch.bat
  • That completes the LLMozLib build - the files that are copied (relative to the Second Life client directory) are:
Header file (llmozlib.h) in libraries\include\
Static library (llmozlib.lib) (debug) in libraries\i686-win32\lib_debug\
Static library (llmozlib.lib) (release) in libraries\i686-win32\lib_release\
Runtime DLLs (debug) in libraries\i686-win32\lib_debug\
Runtime DLLs (release) in libraries\i686-win32\lib_release\
Runtime misc files (debug) in indra\newview\app_settings\mozilla_debug\
Runtime misc files (release) in indra\newview\app_settings\mozilla_release\

Building

  • Open the \indra\indra_complete\indra_complete.sln solution in Visual Studio.
  • Set newview to be the startup project.
  • Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production).
  • newview.exe will be built in \indra\newview\ReleaseNoOpt or \indra\newview\ReleaseForDownload
  • create a shortcut to newview, and change the start location to \indra\newview\ (all the .dll will be found there.)