Difference between revisions of "Compiling the viewer (MSVS2005)"

From Second Life Wiki
Jump to navigation Jump to search
 
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Languages}}
{{Warning|These instructions will not work with newer versions of the viewer.  See [[Microsoft Windows Builds]] for building the latest version of the viewer.}}
 
{{Multi-lang}}
{{CompileNav}}
{{CompileNav}}
__TOC__
This page explains how to compile the Second Life Viewer on Microsoft Windows.
There are several options for the build (compile) environment.


This page explains how you can compile the viewer on Microsoft Windows using Visual Studio 2005 or Visual C++ Express 2005Note 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 the list of [[Microsoft Visual Studio|supported Visual studio editions]] and you will get less trouble with it than with VS2005.
Currently, only the 32-bit binary is testedThere are attempts to produce a 64-bit Windows executable.  If you did this, please write your experience on [[Talk:Microsoft Windows Builds|the discussion page]] (regardless of whether it was successful or not!)


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 [http://wiki.secondlife.com/w/index.php?title=Compiling_the_viewer_%28MSVS2005%29&oldid=22294 older version of this page] for the Viewer releases 1.15 or before.
== Choosing and preparing a compiler ==


= Preparing the Development Environment =
=== Linden-supported compilers ===


== Installing/Configuring VS2005 ==
Supported compiler: '''Visual Studio .NET 2005 Professional'''


You need to setup the compiler and Microsoft Development tools as follows:
You need to setup the compiler and Microsoft Development tools as follows:
* Setup [[Microsoft Visual Studio]]
* Setup [[Microsoft Visual Studio]]


== Getting other Development Tools ==
=== Community experimental compilers ===
You will also need some open source development tools.
 
* [http://www.cmake.org/ CMake 2.4.8]
If you don't have Visual Studio .NET 2005 Professional, you may wish to try one of the following alternatives.
* [http://www.cygwin.com/ 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. (If you missed one of these, the easiest thing to do is to re-run the entire installation.) 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.
* Visual C++ 2005 Express ([[Microsoft Visual Studio|instructions]], but the screenshots for [[Compiling the Viewer (MSVS2008)|VS2008]] are worth a glance too)
* [http://www.activestate.com/Products/ActivePython/?mp=1 ActivePython 2.3x or later] - Latest Version seems to be 2.5.2.2.  Compatibility with SL is unsure.
* Visual Studio 2008 ([[Compiling the Viewer (MSVS2008)|instructions]])
** It is required but can be avoided if you are compiling 1.18 or later viewersEither download and install or hack the prebuild.bat files as described in [http://jira.secondlife.com/browse/VWR-1267 VWR-1267].
* Visual C++ 2008 Express ([[Compiling the Viewer (MSVS2008)|instructions]])
* 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.
 
*: [http://www.activestate.com/Products/ActivePerl/?mp=1 ActivePerl]
{{KBwarning|Boost support with Visual Studio 2008 is problematic as of this writingCheck {{jira|VWR-9541}} before continuing on this path.}}
 
{{KBcaution|Make sure you install to paths without spaces in it.}}
 
== Getting other development tools ==


<br />
You will need to install the following tools to compile the Viewer:
<br />
* '''UniCode NSIS''' ([http://code.google.com/p/unsis/downloads/list download Unicode NSIS])
<br />
**  This is the package installer used to build <code>Setup.exe</code>. ''<b>Note:</b> NSIS is now hosted by Google Code (linked above). Previously at: http://www.scratchpaper.com/home/downloads.'' --[[User:Jenn Linden|Jenn Linden]] 21:56, 25 October 2010 (UTC)
** NSIS must be installed to the default location for your windows install, i.e. "Program Files"
* '''CMake''' ([http://www.cmake.org/HTML/Download.html download CMake])
**  Use the latest point version for Cmake 2.6. As of this writing, the latest version is 2.6.4.  <b>Note</b>: There are many known issues with CMake 2.6.0 and 2.6.1 in conjunction with building the Second Life Viewer.  CMake 2.4.8 is supported for compiling the 1.21 version of the Second Life Viewer, but 2.6.2 is likely to become the new minimum requirement in the near future.
* '''Cygwin''' ([http://www.cygwin.com/ download Cygwin])
** When you run the cygwin setup utility make sure you have selected to install '''patchutils''', '''flex''', '''bison''', and '''zlib-devel'''(all located under "devel"), '''openssh''' (located under "Net"), which are not part of the default install. (If you missed one of these, the easiest thing to do is to re-run the entire installation.)
** '''NOTE:''' '''DO NOT''' use the Cygwin version of CMake or Python. The Build will fail. (CMake specifically excludes the Cygwin version of Python, in the <code>Python.cmake</code> file)
* '''Python''' (download either [http://www.python.org/download/ Python.org Standard Python] or  [http://www.activestate.com/Products/ActivePython/?mp=1 ActivePython]
** 2.4.3 is the minimum required version.
**  Use version v2.5 preferably. If you use a version newer than 2.5, you may need to change the <code>Python.cmake</code> file. See the [[Talk:CMake#CMake_and_Python_2.6|CMake discussion]] for details (this change was necessary as of 1.21-r99587 source branch). ) 
* '''The Windows Platform SDK'''
** Get the latest version (as of 23 March 2010) here: [http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=c17ba869-9671-4330-a63e-1fd44e0e2505&displayLang=en Windows SDK for Windows Server 2008 and .NET Framework 3.5 SP1] (If you use the web installer, you can choose only the "Development Tools" and "Samples Win32", which is referenced by viewer-development source, to cut the download size significantly.  Watch those version descriptions closely.  v6.1 seems to work fine but v7.0, when combined with the components above, results in linking errors stating libraries are corrupted.)
* '''DirectX SDK'''
** Get the latest version (as of 7 June 2010) here: [http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba DirectX SDK (June 2010)]


= Downloading Source Code =
Verify that Cygwin, CMake, and Python are in the windows "PATH".


You can download the Viewer source codes on the [[source downloads]] page.  You can also use a [[version control repository]].
== Downloading Source Code ==


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.
{{KBcaution|Make sure you install to paths without spaces in it.}}
 
You can download the Viewer source code on the [[source downloads]] page.  You can also use a [[version control repository]].  If you're just starting out, it's probably best to get the latest Release version, rather than a Release Candidate, because the Release Candidates get updated quite often.  But if you would rather work with the latest code, go for the [[version control repository]] "trunk". Don't forget to also download the artwork and library bundles relevant to the repository branch you're using as explained in [[Version_control_repository#Artwork_and_Library_Bundles|Artwork and Library Bundles]].
 
If you're downloading from the [[source downloads]] page, there are three packages to get: the source package, the artwork package, and the library package.  In versions 1.20 and earlier, Linden packaged the library binaries in the Libs package. For 1.21 and beyond, the CMake <code>develop.py</code> script now downloads '''most''' of the libraries that were previously in the libs zip file.  This saves developers who are tracking trunk from constantly downloading them every update and only downloads updated libraries.  As of this writing, there are some pieces packages that still require downloading, so be sure to grab the library and artwork bundles from the [[source downloads]] page.


'''WARNING:'''
'''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!
* If the directory path you keep the SL source in has a space in it, the batch file that copies <code>message_template.msg</code> will fail. So, if you unzip or checkout the source tree into, e.g., <code>C:\Projects\Dir with space in name\Etc\linden</code>, 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...
* 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.
* 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''.
In other words, the easiest way to get this working is to get '''source''', '''artwork''', and '''libs''' 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 <code>sl_1_21_6</code>.
<br />
<br />
<br />
<br />


= Installing Libraries =
== Installing libraries ==


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


== Open Source Libraries ==
=== 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 [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrfnonstandardbehavior.asp 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 [[Compiling the viewer libraries (MSVS 2003)|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...)
As of Viewer version 1.21, all open source libraries are automatically downloaded as part of the build script invoked by <code>develop.py</code>, unless you choose to configure a standalone build.
<br />
<br />


== Proprietary Libraries ==
=== 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.
Linden Lab does not provide proprietary libraries.  You will need to follow the instructions here under to acquire and copy them to your source tree.


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.
It's probably a good idea to build an empty directory tree for those files, copy the relevant proprietary files there and, once done, copy the whole to your source tree (like <code>XCOPY OLIB SL_1_16_0_5 /S</code>). 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 its own folder).  If you do not want to do this, you can just as well copy the files directly into the linden source paths.


  rem OLIBS.CMD to build a folder tree for 3rd party libraries and includes
  rem OLIBS.CMD to build a folder tree for 3rd party libraries and includes
Line 79: Line 94:
  md olibs\linden\indra
  md olibs\linden\indra
  md olibs\linden\indra\newview
  md olibs\linden\indra\newview
<br />
=== Fmod ===
* Download & extract [http://www.fmod.org/index.php/download fmod 3.75 api for win32], under section heading '''FMOD 3 Programmers API''' (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"
(If using cmake, 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"
<br />


=== OpenGL ===
* Download [http://oss.sgi.com/projects/ogl-sample/sdk.html glext.h, glxext.h, and wglext.h]
* Copy them to "linden\libraries\i686-win32\include\GL"
* You don't need any additional *.lib or *.dll for OpenGL.
<br />


=== ares (viewer 1.18.4 ... for later releases first check if the ares.h and .lib files are in the Linden library package) - works for vs2k8 ===
==== Fmod ====  
* download c-ares 1.4 from [http://daniel.haxx.se/projects/c-ares/ here] and unpack it somewhere
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]. (later versions, like FMOD Ex, are incompatible).
* open vc.dsw from the c-ares/vc folder
* Copy <code>fmodapi375win\api\inc\fmod.h</code> to <code>linden\libraries\include</code>
* remove the adig and ahost projects from the vc workspace
* Copy <code>fmodapi375win\api\inc\fmod_errors.h</code> to <code>linden\libraries\include</code>
* add ares_getnameinfo.c to the areslib project
* Copy <code>fmodapi375win\api\inc\fmoddyn.h</code> to <code>linden\libraries\include</code>
* for both areslib and acountry, right-click, properties, Code Generation and set Runtime Library to /MT (release) and /MTd (debug)
* Copy <code>fmodapi375win\api\lib\fmodvc.lib</code> to <code>linden\libraries\i686-win32\lib_release</code> and to <code>linden\libraries\i686-win32\lib_debug</code>
* compile debug and release
(If using cmake, copy <code>fmodapi375win\api\lib\fmodvc.lib</code> to <code>linden\libraries\i686-win32\lib\release</code> and to <code>linden\libraries\i686-win32\lib\debug</code>)
* copy all c-ares\*.h files to linden\libraries\include\ares\*.h
* Copy <code>fmodapi375win\api\fmod.dll</code> to <code>linden\libraries\i686-win32\lib\release</code> and <code>linden\libraries\i686-win32\lib\debug</code>
* copy vc\areslib\Debug\*lib to linden\libraries\i686-win32\lib_debug
 
* copy vc\areslib\Release\*lib to linden\libraries\i686-win32\lib_release
Note to Snowstorm users: if you are building using the Mercurial repository [https://bitbucket.org/lindenlab/viewer-development lindenlab/viewer-development], these steps have been simplified and cleaned up. In particular, there's no need to drop anything under <code>linden\indra</code> anymore, all the files are under <code>linden\libraries</code> like for other 3rd party libraries. The <code>fmodvc.lib</code> however needs to be renamed <code>fmod.lib</code>. The new instructions are:
<br />
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]
* From <code>fmodapi375win\api\inc\</code>, copy <code>fmod.h</code> and <code>fmod_errors.h</code> to <code>linden\libraries\include</code>
* From <code>fmodapi375win\api\lib</code>, choose the relevant <code>.lib</code> that correspond to your environment (e.g. <code>fmodvc.lib</code> for Visual Studio), rename it <code>fmod.lib</code> and copy it to <code>linden\libraries\i686-win32\lib\release</code> and <code>linden\libraries\i686-win32\lib\debug</code>
* From <code>fmodapi375win\api</code> copy <code>fmod.dll</code> to <code>linden\libraries\i686-win32\lib\release</code> and <code>linden\libraries\i686-win32\lib\debug</code>
 
==== Quicktime ====
 
Currently - as of version 1.21 - CMake requires Quicktime to be installed.
 
'''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 [[Compiling_older_Viewers_(1.20_and_earlier_with_MSVS)#QuickTime_removal|this]] for details.  Remember that your Viewer '''can't play in-world movies''' if you do so.
* Download & install the [http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/11.1.17.2.1.3.3.1.0.1.1.0.3.11.3.3.1#main Quicktime SDK for Windows]
* Copy <code>QuicktimeSDK\Libraries\QTMLClient.lib</code> to <code>linden\libraries\i686-win32\lib_release</code> and to <code>linden\libraries\i686-win32\lib_debug</code>.
 
(If using CMake, copy <code>QuicktimeSDK\Libraries\QTMLClient.lib</code> to <code>linden\libraries\i686-win32\lib\release</code> and to <code>linden\libraries\i686-win32\lib\debug</code> instead)
 
* Copy the contents of <code>QuicktimeSDK\CIncludes</code> into <code>linden\libraries\i686-win32\include\quicktime</code>.
 
== Building the Viewer ==
 
At this point, you should be ready to use [[CMake]] to build the Visual Studio solution for the project.
 
'''NOTE''': CMake is only supported for Viewer versions 1.21 and beyond.
 
Before you first run a build, you'll need to configure things. It is recommended that you use the <code>develop.py</code> script that will create a default configuration for you.


=== openjpeg (viewer 1.18.4 ... for later releases first check if the openjpeg.lib files are in the Linden library package) ===
You must make sure that cmake is registered in the Windows environment or you will get strange errors from <code>develop.py</code>. To ensure everything is correct, right click My Computer -> Properties -> Advanced -> Environment Variables -> Inside System Variables, choose PATH (case insensitive) and click Edit. Now in the value field, go to the end of the value and add a semicolon (<code>;</code>), and then the folder containing the CMake binaries (example: <code>C:\Program Files\CMake 2.8\bin</code>). This might already have been set by the CMake installer.
* download the latest OpenJPEG source tar package from [http://www.openjpeg.org/ 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
<br />


=== Quicktime ''(optional)'' ===
From the command line, navigate to the <code>indra</code> folder of your source tree and run:
'''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 [[#QuickTime removal|below]] for details.  Remember that your viewer '''can't play in-world movies''' if you do so.
* Download & install the [http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/203/wa/getSoftware?fileID=20525&code=y&source=x&wosid=4h16WcyMtVfd2P1EffGafkoxFcr 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".
<br />
<br />
<br />


= Configuring for VS2005 =
python develop.py


Lindens mostly use VS2003 to develop the viewer, but 2005 should work even better.
CMake will pick the most recent version of Visual Studio we support. If you want to specify the version of Visual Studio to use.


To configure, go into <code>linden\indra</code> and run <code>develop.py -G VC80</code>.  This will create a build directory named <code>build-VC80</code>.
* VisualStudio 2005:


== Workarounds ==
python develop.py -G VC80


There are more compatibility problems between VS2003 and VS2005.  You might need the following code edits.
* VisualStudio 2008:


<b>Note: probably most or all of this section is out of date.</b>
python develop.py -G VC90


=== test project/crash_logger/updater ===
'''NOTE:''' The above commands 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.


<b>This is probably out of date.</b>
=== Finding your build directory ===


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'''.
In the CMake world, we keep source and object files separate. The <code>develop.py</code> script did create and populate a build directory for you. It is in one of the following locations:
* VS 2005: <code>indra/build-vc80</code>
* VS 2008: <code>indra/build-vc90</code>


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.
=== Compiling ===
<br />
=== QuickTime removal ===


<b>This is definitely out of date.</b>
To start a build, do one of the following:
*  Run <code>python develop.py build</code> from the <code>indra</code> directory.
** '''NOTE FOR VS 2008 USERS:''' This command will not work, since it will only look for VS 2005.  Instead, run the command <code>python develop.py -G VC90 build</code>
*  Load the Visual Studio solution into your IDE.  For MSVS VC++:
** Use "File -> Open -> Project/Solution", and open the <code>linden/indra/build-VC80/SecondLife.sln</code> solution file
*** '''NOTE FOR VS 2008 USERS:''' Even though a build-VC90 was created in the above steps, <code>developer.py</code> places the VS 2008 solution/project files in the <code>indra</code> directory.  Don't move them to <code>build-VC90</code> - the paths in the project files are relative to the <code>indra</code> directory.
** In the MSVS toolbar, just to the right of the triangular "Start Debugging" arrow, is a text box whose tooltip is "Solution Configurations".  Select RelWithDebugInfo.
** If ALL_BUILD is not set as your StartUp Project (the StartUp Project is displayed in bold font), right-click on ALL_BUILD and choose "Set as StartUp Project".
** Right-click on ALL_BUILD and choose "Properties".  In "Configuration Properties -> Debugging", find "Working Directory" and navigate to <code>linden\indra\newview</code>.
** (For Snowglobe 1.x) In the Solution Explorer pane, right-click on the project named "prepare" and select Project Only -> Build Only prepare.  This downloads and installs precompiled libraries and only needs to be done when the source tree is clean or if libraries in the list included in the source tree get updated.  Running this when not required is brief and causes no harm.
** Build -> Build Solution (F7)
** Debug -> "Start Debugging" or "Start without debugging".
** MSVC might not be able to find the executable.  If not, point it to <code>linden\indra\build-VC80\newview\relwithdebinfo\secondlife-bin.exe</code>, and try again.
** You may see an error due to not being able to find <code>fmod.dll</code>.  If so, find a copy (remember, you copied this in a step above) and copy it into <code>indra\build-VC80\newview\relwithdebinfo</code>.  Try again.
** You may see an error due to not finding <code>llkdu.dll</code>. If so, find it in the normal installed version (make sure it's the same version as your source) and copy it into <code>indra\build-VC80\newview\relwithdebinfo</code>.  Try again.
** Good luck!


If you don't want to get Apple QuickTime SDK, you can disable it as follows:
=== Where's the built Viewer? ===
*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
On Windows, the built Viewer ought to run from VS2005.


* 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:
To run outside MS VS, see Discussion tab:
*Click '''newview''' to select it alone.
[[Talk:Microsoft_Windows_Builds#Running_viewer_outside_of_MS_VS]]
**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.
<br />
<br />
<br />


= Ready, Set, Build! =
=== Build instructions for 1.20 and earlier ===


== Building ==
See [[Compiling older Viewers (1.20 and earlier with MSVS)]] if you'd like to compile a version of the Viewer older than 1.20.
* Build either '''RelWithDebInfo''' (for debugging) or '''Release''' (for production code).
* To do this, pick either in the Solution Configurations drop-down box beside the green arrow under the tool bar.
* Select Build-Menu > Build Solution or press F7.
<br />


== Common compile errors ==
== What to do if it doesn't work for you ==
* See [[common compilation problems]] if you run into other errors while building.
<br />
== 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.
<br />
== Debugging Info/Configurations ==
<b>This section is out of date.</b>


* Usually you will either use '''ReleaseNoOpt''' or the '''ReleaseForDownload''' configuration.
* Ask for help on [[IRC]] ([irc://irc.freenode.net/opensl #opensl on freenode])
* '''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.
* Find someone on the [[OpenSource-Dev|OpenSource-Dev mailing list]]
* '''ReleaseForDownload''' also has debugging information and runs fine in the debugger (although at times you may miss access to some local variables).
* Fix it: [[Modifying CMake Files‎]] (and please, submit a patch!)
* '''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]]
<br />


== Problems Running? ==
Please also see the (user contributed) instructions at [[User:Michelle2_Zenovka/cmake]]
* '''Inventory errors''': If you're getting errors while trying to load your inventory, try [[Help:Stuck logging in|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).
<br />
<br />
= 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]].


[[Category:Compiling viewer]]
[[Category:Compiling viewer]]

Latest revision as of 10:25, 19 August 2011

Warning!

These instructions will not work with newer versions of the viewer. See Microsoft Windows Builds for building the latest version of the viewer.


This page explains how to compile the Second Life Viewer on Microsoft Windows. There are several options for the build (compile) environment.

Currently, only the 32-bit binary is tested. There are attempts to produce a 64-bit Windows executable. If you did this, please write your experience on the discussion page (regardless of whether it was successful or not!)


Choosing and preparing a compiler

Linden-supported compilers

Supported compiler: Visual Studio .NET 2005 Professional

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

Community experimental compilers

If you don't have Visual Studio .NET 2005 Professional, you may wish to try one of the following alternatives.

KBwarning.png Warning: Boost support with Visual Studio 2008 is problematic as of this writing. Check VWR-9541 before continuing on this path.
KBcaution.png Important: Make sure you install to paths without spaces in it.

Getting other development tools

You will need to install the following tools to compile the Viewer:

  • UniCode NSIS (download Unicode NSIS)
    • This is the package installer used to build Setup.exe. Note: NSIS is now hosted by Google Code (linked above). Previously at: http://www.scratchpaper.com/home/downloads. --Jenn Linden 21:56, 25 October 2010 (UTC)
    • NSIS must be installed to the default location for your windows install, i.e. "Program Files"
  • CMake (download CMake)
    • Use the latest point version for Cmake 2.6. As of this writing, the latest version is 2.6.4. Note: There are many known issues with CMake 2.6.0 and 2.6.1 in conjunction with building the Second Life Viewer. CMake 2.4.8 is supported for compiling the 1.21 version of the Second Life Viewer, but 2.6.2 is likely to become the new minimum requirement in the near future.
  • Cygwin (download Cygwin)
    • When you run the cygwin setup utility make sure you have selected to install patchutils, flex, bison, and zlib-devel(all located under "devel"), openssh (located under "Net"), which are not part of the default install. (If you missed one of these, the easiest thing to do is to re-run the entire installation.)
    • NOTE: DO NOT use the Cygwin version of CMake or Python. The Build will fail. (CMake specifically excludes the Cygwin version of Python, in the Python.cmake file)
  • Python (download either Python.org Standard Python or ActivePython
    • 2.4.3 is the minimum required version.
    • Use version v2.5 preferably. If you use a version newer than 2.5, you may need to change the Python.cmake file. See the CMake discussion for details (this change was necessary as of 1.21-r99587 source branch). )
  • The Windows Platform SDK
    • Get the latest version (as of 23 March 2010) here: Windows SDK for Windows Server 2008 and .NET Framework 3.5 SP1 (If you use the web installer, you can choose only the "Development Tools" and "Samples Win32", which is referenced by viewer-development source, to cut the download size significantly. Watch those version descriptions closely. v6.1 seems to work fine but v7.0, when combined with the components above, results in linking errors stating libraries are corrupted.)
  • DirectX SDK

Verify that Cygwin, CMake, and Python are in the windows "PATH".

Downloading Source Code

KBcaution.png Important: Make sure you install to paths without spaces in it.

You can download the Viewer source code on the source downloads page. You can also use a version control repository. If you're just starting out, it's probably best to get the latest Release version, rather than a Release Candidate, because the Release Candidates get updated quite often. But if you would rather work with the latest code, go for the version control repository "trunk". Don't forget to also download the artwork and library bundles relevant to the repository branch you're using as explained in Artwork and Library Bundles.

If you're downloading from the source downloads page, there are three packages to get: the source package, the artwork package, and the library package. In versions 1.20 and earlier, Linden packaged the library binaries in the Libs package. For 1.21 and beyond, the CMake develop.py script now downloads most of the libraries that were previously in the libs zip file. This saves developers who are tracking trunk from constantly downloading them every update and only downloads updated libraries. As of this writing, there are some pieces packages that still require downloading, so be sure to grab the library and artwork bundles from the source downloads page.

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 libs 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_21_6.

Installing libraries

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

Open source libraries

As of Viewer version 1.21, all open source libraries are automatically downloaded as part of the build script invoked by develop.py, unless you choose to configure a standalone build.

Proprietary libraries

Linden Lab does not provide proprietary libraries. You will need to follow the instructions here under to acquire and copy them to your source tree.

It's probably a good idea to build an empty directory tree for those files, copy the relevant proprietary files there and, once done, copy the whole to your source tree (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 its own folder). If you do not want to do this, you can just as well 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 FMOD3.75 API for Windows. (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\inc\fmoddyn.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

(If using cmake, 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\libraries\i686-win32\lib\release and linden\libraries\i686-win32\lib\debug

Note to Snowstorm users: if you are building using the Mercurial repository lindenlab/viewer-development, these steps have been simplified and cleaned up. In particular, there's no need to drop anything under linden\indra anymore, all the files are under linden\libraries like for other 3rd party libraries. The fmodvc.lib however needs to be renamed fmod.lib. The new instructions are:

  • Download & extract FMOD3.75 API for Windows
  • From fmodapi375win\api\inc\, copy fmod.h and fmod_errors.h to linden\libraries\include
  • From fmodapi375win\api\lib, choose the relevant .lib that correspond to your environment (e.g. fmodvc.lib for Visual Studio), rename it fmod.lib and copy it to linden\libraries\i686-win32\lib\release and linden\libraries\i686-win32\lib\debug
  • From fmodapi375win\api copy fmod.dll to linden\libraries\i686-win32\lib\release and linden\libraries\i686-win32\lib\debug

Quicktime

Currently - as of version 1.21 - CMake requires Quicktime to be installed.

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

(If using CMake, copy QuicktimeSDK\Libraries\QTMLClient.lib to linden\libraries\i686-win32\lib\release and to linden\libraries\i686-win32\lib\debug instead)

  • Copy the contents of QuicktimeSDK\CIncludes into linden\libraries\i686-win32\include\quicktime.

Building the Viewer

At this point, you should be ready to use CMake to build the Visual Studio solution for the project.

NOTE: CMake is only supported for Viewer versions 1.21 and beyond.

Before you first run a build, you'll need to configure things. It is recommended that you use the develop.py script that will create a default configuration for you.

You must make sure that cmake is registered in the Windows environment or you will get strange errors from develop.py. To ensure everything is correct, right click My Computer -> Properties -> Advanced -> Environment Variables -> Inside System Variables, choose PATH (case insensitive) and click Edit. Now in the value field, go to the end of the value and add a semicolon (;), and then the folder containing the CMake binaries (example: C:\Program Files\CMake 2.8\bin). This might already have been set by the CMake installer.

From the command line, navigate to the indra folder of your source tree and run:

python develop.py

CMake will pick the most recent version of Visual Studio we support. If you want to specify the version of Visual Studio to use.

  • VisualStudio 2005:
python develop.py -G VC80
  • VisualStudio 2008:
python develop.py -G VC90

NOTE: The above commands 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.

Finding your build directory

In the CMake world, we keep source and object files separate. The develop.py script did create and populate a build directory for you. It is in one of the following locations:

  • VS 2005: indra/build-vc80
  • VS 2008: indra/build-vc90

Compiling

To start a build, do one of the following:

  • Run python develop.py build from the indra directory.
    • NOTE FOR VS 2008 USERS: This command will not work, since it will only look for VS 2005. Instead, run the command python develop.py -G VC90 build
  • Load the Visual Studio solution into your IDE. For MSVS VC++:
    • Use "File -> Open -> Project/Solution", and open the linden/indra/build-VC80/SecondLife.sln solution file
      • NOTE FOR VS 2008 USERS: Even though a build-VC90 was created in the above steps, developer.py places the VS 2008 solution/project files in the indra directory. Don't move them to build-VC90 - the paths in the project files are relative to the indra directory.
    • In the MSVS toolbar, just to the right of the triangular "Start Debugging" arrow, is a text box whose tooltip is "Solution Configurations". Select RelWithDebugInfo.
    • If ALL_BUILD is not set as your StartUp Project (the StartUp Project is displayed in bold font), right-click on ALL_BUILD and choose "Set as StartUp Project".
    • Right-click on ALL_BUILD and choose "Properties". In "Configuration Properties -> Debugging", find "Working Directory" and navigate to linden\indra\newview.
    • (For Snowglobe 1.x) In the Solution Explorer pane, right-click on the project named "prepare" and select Project Only -> Build Only prepare. This downloads and installs precompiled libraries and only needs to be done when the source tree is clean or if libraries in the list included in the source tree get updated. Running this when not required is brief and causes no harm.
    • Build -> Build Solution (F7)
    • Debug -> "Start Debugging" or "Start without debugging".
    • MSVC might not be able to find the executable. If not, point it to linden\indra\build-VC80\newview\relwithdebinfo\secondlife-bin.exe, and try again.
    • You may see an error due to not being able to find fmod.dll. If so, find a copy (remember, you copied this in a step above) and copy it into indra\build-VC80\newview\relwithdebinfo. Try again.
    • You may see an error due to not finding llkdu.dll. If so, find it in the normal installed version (make sure it's the same version as your source) and copy it into indra\build-VC80\newview\relwithdebinfo. Try again.
    • Good luck!

Where's the built Viewer?

On Windows, the built Viewer ought to run from VS2005.

To run outside MS VS, see Discussion tab: Talk:Microsoft_Windows_Builds#Running_viewer_outside_of_MS_VS

Build instructions for 1.20 and earlier

See Compiling older Viewers (1.20 and earlier with MSVS) if you'd like to compile a version of the Viewer older than 1.20.

What to do if it doesn't work for you

Please also see the (user contributed) instructions at User:Michelle2_Zenovka/cmake