Compiling the viewer (MSVS2005)

From Second Life Wiki
Jump to navigation Jump to search

This page explains how you can compile the viewer on Microsoft Windows using Visual Studio 2005 or Visual C++ Express 2005. Note that Lindens are using VS2003 and the whole setup is a bit easier there, so if you have Visual Studio 2003 available, you should read compiling with VS2003 and you will get less trouble with it than with VS2005.

Currently, only 32 bit binary is tested. There seems to be several trials to produce 64 bit Windows .EXE of the viewer. If you did, please write your experience on this wiki (regardless it was successful or not!)

The following explanation is adjusted for Viewer releases 1.16.0.5 or later. See an older version of this page for the Viewer releases 1.15 or before.

Preparing the Development Environment

Installing/Configuring VS2005

You need to setup the compiler and Microsoft Development tools as follows:

Getting other Development Tools

You will also need some open source development tools.

  • Cygwin
    • When you run the cygwin setup utility make sure you have selected to install patchutils, flex, and bison (all located under "devel") which are not part of the default install. Older releases (< r79209) had several hardcoded references that expect Cygwin to be installed at C:\cygwin in the project files, however current releases rely on the build environment configuration instead.
  • ActivePython 2.3x or later - Latest Version is 2.5.1.1
    • It is required but can be avoided if you are compiling 1.18 or later viewers. Either download and install or hack the prebuild.bat files as described in VWR-1267.
  • ActivePerl was recommended for previous versions on this Wiki, but it currently appears, that it is not strictly necessary unless you are planning to build your own version of all libraries (which most likely you don't want to do). So for a start it may be safe to skip it.
    ActivePerl




Downloading Source Code

You can download the Viewer source codes on the source downloads page. You can also use a version control repository.

At a minimum, grab the source package and the artwork package, but for a start, also grab the library archive. Many of the libraries can either be compiled from source or downloaded from other sites (see below), but this will take hours and thus it is easiest to also get the package with libraries compiled by the Lindens.

WARNING:

  • If the directory path you keep the SL source in has a space in it, the batch file that copies message_template.msg will fail. So, if you unzip or checkout the source tree into, e.g., "C:\Projects\Dir with space in name\Etc\linden", it won't work!
  • You should also avoid using non-ASCII (national) characters in the paths, although some localized versions of the tool puts some as a default...
  • Unzip or checkout your source tree into a directory that has as short full pathname as possible, since long paths cause some unexpected trouble during the build.

In other words, the easiest way to get this working is to get source, artwork and libraries from the source downloads page and unpack them all into the same directory/folder, which ideally would be a folder in (or near) the root directory with a short name like sl_1_16_0_5.



Installing Libraries

SL Viewer depends on some third party libraries. Some of them are open source, some others are not.

Open Source Libraries

You can download the pre-build open source libraries from LL. They are available on source downloads page. Unzip them into your SL viewer source code directory, maintaining the same directory structure.

Note: The VS2003 libraries provided in the source downloads do not fully work with VS2005 compiled binaries. They will compile with the viewer under VS2005, but the VS2003 libraries are not fully STL compliant. The differences of non-standard behavior in MSVS are the known cause.

Alternatively, it may be possible to get the source files for the libraries and build by yourself. See the instruction for VS2003 users if you try it. Please note, however, it is not known that VS2005 can successfully compile the libraries. You have been warned. (If you can make it, please write the info on this wiki...)

Proprietary Libraries

Lindens does not inlcude the following proprietary libraries. You will need to follow the instructions to acquire below and copy them to the source path.

However, it probably is a good idea to build an empty directory tree for the files below and first copy the files there and once completed, copy the whole tree to the actual source folder (like XCOPY OLIB SL_1_16_0_5 /S). The reason is, that these steps are cumbersome and will have to be repeated for each new release (at least if you keep the source for each release in it's own folder). If you do not want to do this, of course you can just copy the files directly into the linden source paths.

rem OLIBS.CMD to build a folder tree for 3rd party libraries and includes
md olibs
md olibs\linden\
md olibs\linden\libraries
md olibs\linden\libraries\include
md olibs\linden\libraries\i686-win32
md olibs\linden\libraries\i686-win32\lib_release
md olibs\linden\libraries\i686-win32\lib_debug
md olibs\linden\libraries\i686-win32\include
md olibs\linden\libraries\i686-win32\include\GL
md olibs\linden\libraries\i686-win32\include\quicktime
md olibs\linden\indra
md olibs\linden\indra\newview


Fmod

  • Download & extract fmod 3.75 api for win32 (later versions, like FMOD Ex, are incompatible).
  • Copy "fmodapi375win\api\inc\fmod.h" to "linden\libraries\include"
  • Copy "fmodapi375win\api\inc\fmod_errors.h" to "linden\libraries\include"
  • Copy "fmodapi375win\api\lib\fmodvc.lib" to "linden\libraries\i686-win32\lib_release" and to "linden\libraries\i686-win32\lib_debug"
  • Copy "fmodapi375win\api\fmod.dll" to "linden\indra\newview"


OpenGL


ares (viewer 1.18.4 ... for later releases first check if the ares.h and .lib files are in the Linden library package)

  • download c-ares 1.4 from here and unpack it somewhere
  • open vc.dsw from the c-ares/vc folder
  • remove the adig and ahost projects from the vc workspace
  • add ares_getnameinfo.c to the areslib project
  • for areslib right-click, properties, Code Generation and set Runtime Library to /MT (release) and /MTd (debug)
  • compile debug and release
  • copy all c-ares\*.h files to linden\libraries\include\ares\*.h
  • copy vc\areslib\Debug\*lib to linden\libraries\i686-win32\lib_debug
  • copy vc\areslib\Release\*lib to linden\libraries\i686-win32\lib_release


openjpeg (viewer 1.18.4 ... for later releases first check if the openjpeg.lib files are in the Linden library package)

  • download the latest OpenJPEG from here
  • open the libopenjpeg.dsw, let it convert and compile it (you'll need the files from the dllopenjpeg sub-project)
  • copy debug\openjpeg.lib to linden\libraries\i686-win32\lib_debug
  • copy release\openjpeg.lib to linden\libraries\i686-win32\lib_release
  • copy release\openjpeg.dll to linden\indra\newview


Quicktime (optional)

Note: This download requires a registration at the Apple Quicktime website and take a bit of time. You can avoid using QuickTime if you want, see below for details. Remember that your viewer can't play in-world movies if you do so.

  • Download & install the Quicktime SDK for Windows
  • Copy "QuicktimeSDK\Libraries\QTMLClient.lib" to "linden\libraries\i686-win32\lib_release" and to "linden\libraries\i686-win32\lib_debug".
  • Copy the contents of "QuicktimeSDK\CIncludes" into "linden\libraries\i686-win32\include\quicktime".




Configuring for VS2005

Lindens use VS2003 to develop the viewer.

You either need to convert solution file and project files from VS2003 format to VS2005 format or obtain files compatible with VS2005. You may also need to modify source files to work around the incompatibility between VS2003 and VS2005.

Note: linden\indra\indra_complete_vs8.sln is a solution file already included in the source archive and intended for the Visual Studio 2005, but it does not work (at least between 1.14.0 and 1.17.0.9 distribution). This may change in a future release, if Lindens include an updated versions of the _vc8 files.



Using pre-built solution/project files

Currently there is a ZIP file with solution/project files available on the JIRA bug tracker issue VWR-1151.

If you are building 1.16 or later, the easiest way towards compiling SL on MS2005 will be to use the zip file mentioned above. The details is as follows:

  • Download the appropriate ZIP archive from JIRA.
  • Unpack it and copy it onto your linden source tree (allow to overwrite files that have _vc8 in the name).
  • Start Visual Studio 2005 (or VC++ Express).
  • Use "File > Open > Project/Solution" to open the linden\indra\indra_complete\indra_complete_vc8.sln (Note: If you plan to work with multiple versions over time, you will find it useful to rename indra_complete_vc8.sln to something which contains the version number, e.g. indra_1_17_0_11_vc8.sln before opening.)
  • Right click newview in the frame Solution Explorer and click "Set as StartUp Project".
  • Proceed with applying the Workarounds below (skip Manual conversion).

Note: The solution/project files depends on the viewer release version. If you are compiling some specific version of the viewer, and the VWR-1151 doesn't list the zip file for you version, you can try using the most close one. If, while compiling, you later encounter errors or problems regarding the projects, you may have to do the manual conversion instead.


Manual conversion of the solution/projects

If you can not find a set of project files (see above), there are instructions available how to manually do it: Converting_project_files_for_MSVS2005 (this step will take about 5-15 minutes, depending on how proficient you are using VS2005).




Workarounds

There are more compatibility problems between VS2003 and VS2005. You need the following code edits.

test project/crash_logger/updater

For whatever reason, the test project doesn't work under VS2005. Workaround is to disable it as follows: Right click on the test and choose Unload Project.

If you do not plan to create a full download build, you can exclude the win_crash_logger and win_updater from newview's project dependencies and unload them also. But be careful with unloading these projects without removing them from the dependencies, because I have seen VS2005 act highly erratic while linking then project when I tried this.

QuickTime removal

If you don't want to get Apple QuickTime SDK, you can disable it as follows:

  • linden\indra\llcommon\llpreprocessor.h - near line 58 (the line below #elif LL_WINDOWS)
--50: #define LL_QUICKTIME_ENABLED	1
++50: #define LL_QUICKTIME_ENABLED	0
  LearCale: this appears to be in linden\indra\llmedia\llmediabase.h as of client 1.20
  • Pick ReleaseNoOpt in the Solution Configurations drop-down box beside the green arrow under the tool bar, and do the followings on the Solution Explorer frame:
  • Click newview to select it alone.
    • Choose Properties.
    • Under Configuration Properties > Linker > Input, click Additional Dependencies on the right to show a button labeled "..." on it at the very right on the line, then click the ... button.
    • Scroll down the list to find qtmlclient.lib. Delete this single line.
    • Click OK to close the "Additional Dependencies" dialog, then click OK again to close the "newview Property Pages" dialog box.
  • Pick ReleaseForDownload in the Solution Configurations drop-down box. Click newview to select it alone and do the same thing again.




Ready, Set, Build!

Building

  • Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production code).
  • To do this, pick either in the Solution Configurations drop-down box beside the green arrow under the tool bar.
  • Make sure newview is set as the startup project (otherwise set from newview's right-click menu).
  • Select Build-Menu > Build Solution or press F7.
  • newview_noopt.exe will be built in linden\indra\newview\ReleaseNoOpt or SecondLife.exe will be linden\indra\newview\ReleaseForDownload.


Common compile errors


Running

  • You can run the viewer by Debug > Start Debugging or Debug > Start Without Debugging in Visual Studio.
  • To run it outside VS, create a shortcut to SecondLife.exe, and change the start location to linden\indra\newview\ (All the .dll will be found there.)
  • Alternately copy the exe (possibly rename it) to your "c:\program files\secondlife" folder.


Debugging Info/Configurations

  • Usually you will either use ReleaseNoOpt or the ReleaseForDownload configuration.
  • ReleaseNoOpt (not optimized) compiles faster and has more debugging information, but this comes at a runtime penalty of about 50% of your FPS in busy areas, compared to ReleaseForDownload build.
  • ReleaseForDownload also has debugging information and runs fine in the debugger (although at times you may miss access to some local variables).
  • ReleaseNoOpt comes with a seperate debugging console window opens and stays open for the duration of your session, but you can access the same information also by pressing Shift+Ctrl+4 in the viewer (all builds).
  • The debug console log can also be redirected to a file if you add "2>secondlife.log" to the command line (Newview, Properties, Debugging, Command line arguments).
  • If you want to build a Debug configuration, see the specific section with compile instructions on finding leaks


Problems Running?

  • Inventory errors: If you're getting errors while trying to load your inventory, try clearing your cache and deleting other temporary files.
  • Missing smime3 DLL: Those are parts of the integrated web browser. Copy 'smime3.dll', 'nss3.dll', 'softokn3.dll', and 'ssl3.dll' files from your official client's main folder to "linden\indra\newview".
  • Can't connect: In the debug builds there is a selection box on the login screen to select the server to connect to. Agni is the production grid, aditi is the beta grid. (There seems to be a bug in this part of the code, you may have to make your selection, close the viewer and repoen it, before you can connect to the selected grid).



Submit Patches

This is probably faaar down the road, but if you make changes to the source and want to submit them, see the page about submitting patches.