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

From Second Life Wiki
Jump to navigation Jump to search
(Added patch instructions for new Version slviewer-src-20070112a of the source)
 
(169 intermediate revisions by 44 users not shown)
Line 1: Line 1:
{|align=right
{{Warning|These instructions will not work with newer versions of the viewer. See [[Microsoft Windows Builds]] for building the latest version of the viewer.}}
  |__TOC__
  |}
== Introduction ==
The 2005 version of the Microsoft compiler upgrades the way it handles 64 bit architecture. In order to compile under the 2005 version, you will need to do some edits to the code where typecasts were lazily handled before, as they cause errors now. You'll also will find some POSIX names deprecated and replaced by ISO C++ standards. Be sure to refer to the other [[Compiling the viewer (MS Windows)|compilation steps]] with the 2003 version for more help.


== Prerequisites ==
{{Multi-lang}}
* Visual Studio 2005 '''''-or-''''' [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 Express]<small>(Free)</small>
{{CompileNav}}
** [http://www.microsoft.com/downloads/details.aspx?familyid=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en Microsoft Platform SDK]
__TOC__
** A DirectX 9.0 SDK released on or after Summer of 2003 [http://download.microsoft.com/download/5/1/f/51ff8357-0af3-418b-9d0b-e9a5cdc39759/dxsdk_dec2006.EXE DirectX 9.0 SDK (December 2006)] [http://www.microsoft.com/downloads/details.aspx?FamilyID=9216652f-51e0-402e-b7b5-feb68d00f298&displaylang=en DirectX 9.0 SDK Update (Summer 2003)]
This page explains how to compile the Second Life Viewer on Microsoft Windows.
*** Note: If you have previously installed an older version of the DirectX 9.0 SDK, remove it first (from Control Panel -> Add or Remove Programs) before installing this version.  Installing the new SDK "on top" of an older version may cause problems.
There are several options for the build (compile) environment.
** Set up the project globals:
*** Start Microsoft Visual Studio 2005
*** Go to Tools/Options/Projects/VC++ Directories
*** Make sure that the '''includes'''[[:Image:MSVS2005 Global Project Options Include Files.JPG|('''screen shot''')]] and '''libraries'''[[:Image:MSVS2005 Global Project Options Library Files.JPG|('''screen shot''')]] paths have the Platform SDK paths first, then the DirectX SDK paths, and then the Visual C++ paths. You may need to check "Show All Settings" at the bottom for VC++ Directories to show.
*** If the DirectX SDK paths aren't present, add them to both '''includes''' and '''libraries'''.
* [http://www.cygwin.com/ Cygwin]
** When you run the cygwin setup utility make sure you have selected to install patchutil, flex, and bison (all located under "devel") which are not part of the default install. The project files use several hardcoded references that expect Cygwin to be installed at C:\cygwin, if it's not you'll need to edit those references.


== Libraries ==
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 [[Talk:Microsoft Windows Builds|the discussion page]] (regardless of whether it was successful or not!)


Download the library directory from LL, extract it, and copy the files into your SL viewer source code directory, maintaining the same directory structure.  Includeded are all the libraries LL ships in this file, but LL does not distribute the source to the following, and you will need to follow the instructions to acquire below:


=== Fmod ===
== Choosing and preparing a compiler ==
* Download & extract [http://www.fmod.org/ifmoddownload.html fmod 3.75 api for win32].
* 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"
* Copy "fmodapi375win\api\lib\fmodvc.lib" to "linden\libraries\i686-win32\lib_debug"
* Copy "fmodapi375win\api\fmod.dll" to "linden\indra\newview"


=== gl ===
=== Linden-supported compilers ===
* Download [http://oss.sgi.com/projects/ogl-sample/sdk.html glext.h, glxext.h, and wglext.h]
* Copy them to "libraries\i686-win32\include\GL"


=== Quicktime ===
Supported compiler: '''Visual Studio .NET 2005 Professional'''
* Download & install the [http://developer.apple.com/quicktime/download/ 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\i686-win32\include\quicktime".


=== Boost++ ===
You need to setup the compiler and Microsoft Development tools as follows:
Update boost from vc71 to vc80:
* Setup [[Microsoft Visual Studio]]
* [http://www.boost-consulting.com/download.html Download & install Boost++]
* Open the Visual Studio 2005 Command Prompt
* Delete "linden\libraries\include\boost"
* Copy "%programfiles%\boost\boost1_33_1\boost" to "linden\libraries\include"
* Copy "%programfiles%\boost\boost_1_33_1\lib\libboost_regex-vc80-mt-s-1_33_1.lib"
:# to "\linden\libraries\i686-win32\lib_release" and
:# to "\linden\libraries\i686-win32\lib_debug"
* Right click on the ''newview'' project, and select '''Properties'''
* [[:Image:MSVS2005 newview Property Pages Config Linker Input.JPG|('''screen shot''')]] Under '''Configuration Properties''', '''Linker''', '''Input'''
** find and change "''libboost_regex-vc71-mt-s.lib''"[[:Image:MSVS2005 newview Property Pages Config Linker Input.JPG|('''screen shot''')]] to "''libboost_regex-vc80-mt-s-1_33_1.lib''"[[:Image:MSVS2005 newview Property Pages Config Linker Input List Changed.JPG|('''screen shot''')]] in the ''Additional Dependencies''


=== unistd.h (Express only) ===
=== Community experimental compilers ===
* Create an empty file "linden\libraries\include\unistd.h"


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


== First Steps ==
* Visual C++ 2005 Express ([[Microsoft Visual Studio|instructions]], but the screenshots for [[Compiling the Viewer (MSVS2008)|VS2008]] are worth a glance too)
=== Environment Setup ===
* Visual Studio 2008 ([[Compiling the Viewer (MSVS2008)|instructions]])
* Open the \indra\indra_complete\indra_complete.sln solution in Visual Studio 2005.
* Visual C++ 2008 Express ([[Compiling the Viewer (MSVS2008)|instructions]])
* If Visual Studio prompts to update your project files, allow it to do so.  When the results are displayed, you may see warnings, but you should not see any errors.
* Pick either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production) (in the box beside the green arrow under the tool bar). Any of the following changes you make will only apply to this solution configuration.
* Right click newview in the left hand frame and click "Set as StartUp Project".
* Right click on each project in the solution, with the exception of ''lscript_compile_fb'', and follow these steps for each:
:#[[:Image:MSVS2005_Project_Property_Pages_Config_CPP_General.JPG|('''screen shot''')]] Under '''Configuration Properties''', '''C/C++''', '''General''', change '''Treat Warnings As Errors''' to "''No''"
:#[[:Image:MSVS2005 Project Property Pages Config CPP Preprocessor.JPG |('''screen shot''')]] Under '''Configuration Properties''', '''C/C++''', '''PreProcessor''', insert the line "'';_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE''"
:#[[:Image:MSVS2005 Project Property Pages Config CPP Language.JPG|('''screen shot''')]] Under '''Configuration Properties''', '''C/C++''', '''Language''', change '''Treat wchar_t as Built-in Type''' to "''No (/Zc:wchar_t-)''"
** You must set the PreProcessor definitions for each project individually, but for the other two settings you can highlight all of the project files at the same time (except lscript_compile_fb) and change them simultaneously
*for the "llwindow" project an additional define is required
** Under '''Configuration Properties''', '''C/C++''', '''PreProcessor''', insert the line "'';_CRT_NON_CONFORMING_SWPRINTFS''"
*for the "llmessage" project an additional define is required
** Under '''Configuration Properties''', '''C/C++''', '''PreProcessor''', insert the line "'';_SCL_SECURE_NO_DEPRECATE''"


=== Code Editing ===
{{KBwarning|Boost support with Visual Studio 2008 is problematic as of this writing.  Check {{jira|VWR-9541}} before continuing on this path.}}


==== Version: slviewer-src-20070108c ====
{{KBcaution|Make sure you install to paths without spaces in it.}}
Use CTRL+G to help find these lines and edit them, likewise:


*In linden\indra\llcommon\llstringtable.h @ line 103
== Getting other development tools ==
--103: typedef std::hash_multimap<U32, LLStringTableEntry *> string_hash_t;
++103: typedef std'''''ext'''''::hash_multimap<U32, LLStringTableEntry *> string_hash_t;


*In linden\indra\llcommon\llerror.h @ line 38, and linden\indra\win_updater\updater.cpp @ line 40
You will need to install the following tools to compile the Viewer:
++#if LL_WINDOWS
* '''UniCode NSIS''' ([http://code.google.com/p/unsis/downloads/list download Unicode NSIS])
++# if (_MSC_VER >= 1400)
**  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)
  ++pragma warning(disable : 4996)
** NSIS must be installed to the default location for your windows install, i.e. "Program Files"
++# endif
* '''CMake''' ([http://www.cmake.org/HTML/Download.html download CMake])
++#endif
** 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)]


*In linden\indra\llcommon\u64.cpp @ line 36
Verify that Cygwin, CMake, and Python are in the windows "PATH".
--36: char *aptr = strpbrk(str,"0123456789");
++36: '''''const''''' char *aptr = strpbrk(str,"0123456789");


*linden\indra\llprimitive\llprimitive.cpp @ line 1200
== Downloading Source Code ==
--1200: exception_faces |= (1 << i);
++1200: exception_faces |= ((U64)1 << i);


*linden\indra\llui\llsliderctrl.cpp @ line 218
{{KBcaution|Make sure you install to paths without spaces in it.}}
--218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10, mPrecision) + 0.5) / pow(10, mPrecision));
++218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10'''''.0''''', mPrecision) + 0.5) / pow(10'''''.0''''', mPrecision));


*linden\indra\llui\llspinctrl.cpp @ line 251
You can download the Viewer source code on the [[source downloads]] pageYou 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]].
  --251: F32 displayed_value = (F32)floor(getValue().asReal() * pow(10, mPrecision) + 0.5) / (F32)pow(10, mPrecision);
  ++251: F32 displayed_value = (F32)floor(getValue().asReal() * pow(10'''''.0''''', mPrecision) + 0.5) / (F32)pow(10'''''.0''''', mPrecision);


*linden\indra\newview\llstartup.cpp @ line 1459
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.
--1459: gUTCOffset = (server_utc_time - now);
++1459: gUTCOffset = (server_utc_time - '''''(S32)'''''now);


*linden\indra\newview\llpaneldirevents.cpp @ line 137, and line 169
'''WARNING:'''
--137: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
* 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!
++137: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);
* 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.


--169: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
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>.
++169: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);


*linden\indra\newview\llfloaterreporter.cpp @ line 668
== Installing libraries ==
--668: msg->addU32Fast(_PREHASH_Time, mcd->mTime);
++668: msg->addU32Fast(_PREHASH_Time, '''''(U32)'''''mcd->mTime);


*linden\indra\newview\llfloaterland.cpp @ line 2609, and line 2878
SL Viewer depends on some third party libraries. Some of them are open source, some others are not.
--2609: S32 now = time(NULL);
++2609: S32 now = '''''(S32)'''''time(NULL);


--2878: S32 now = time(NULL);
=== Open source libraries ===
++2878: S32 now = '''''(S32)'''''time(NULL);


*linden\indra\newview\llfloaterbump.cpp @ line 120
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.
--120: timep = utc_to_pacific_time(mcd->mTime, gPacificDaylightTime);
++120: timep = utc_to_pacific_time('''''(S32)'''''mcd->mTime, gPacificDaylightTime);


*linden\indra\newview\viewer.cpp @ line 2510
=== Proprietary libraries ===
--2510: srand(time(NULL));
++2510: srand('''''(U32)'''''time(NULL));
*linden\indra\newview\llurlwhitelist.cpp @ line 43
--43: mUrlListIter ( 0 )
++43: mUrlListIter ( '''''LLUrlWhiteList::mUrlListIter''''' )


==== Version: slviewer-src-20070112a ====
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.
Use CTRL+G to help find these lines and edit them, likewise:


*In linden\indra\llcommon\llstringtable.h @ line 103
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.
--103: typedef std::hash_multimap<U32, LLStringTableEntry *> string_hash_t;
  ++103: typedef std'''''ext'''''::hash_multimap<U32, LLStringTableEntry *> string_hash_t;


*In linden\indra\llcommon\llerror.h @ line 38, and linden\indra\win_updater\updater.cpp @ line 40
rem OLIBS.CMD to build a folder tree for 3rd party libraries and includes
  ++#if LL_WINDOWS
md olibs
  ++# if (_MSC_VER >= 1400)
md olibs\linden\
  ++# pragma warning(disable : 4996)
md olibs\linden\libraries
  ++# endif
md olibs\linden\libraries\include
  ++#endif
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


*In linden\indra\llcommon\u64.cpp @ line 36
--36: char *aptr = strpbrk(str,"0123456789");
++36: '''''const''''' char *aptr = strpbrk(str,"0123456789");


*linden\indra\llprimitive\llprimitive.cpp @ line 1200
==== Fmod ====
--1200: exception_faces |= (1 << i);
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]. (later versions, like FMOD Ex, are incompatible).
++1200: exception_faces |= ((U64)1 << i);
* Copy <code>fmodapi375win\api\inc\fmod.h</code> to <code>linden\libraries\include</code>
* Copy <code>fmodapi375win\api\inc\fmod_errors.h</code> to <code>linden\libraries\include</code>
* Copy <code>fmodapi375win\api\inc\fmoddyn.h</code> to <code>linden\libraries\include</code>
* 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>
(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 <code>fmodapi375win\api\fmod.dll</code> to <code>linden\libraries\i686-win32\lib\release</code> and <code>linden\libraries\i686-win32\lib\debug</code>


*linden\indra\llui\llsliderctrl.cpp @ line 218
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:
--218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10, mPrecision) + 0.5) / pow(10, mPrecision));
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]
++218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10'''''.0''''', mPrecision) + 0.5) / pow(10'''''.0''''', mPrecision));
* 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>


*linden\indra\llui\llspinctrl.cpp @ line 251
==== Quicktime ====
--251: F32 displayed_value = (F32)floor(getValue().asReal() * pow(10, mPrecision) + 0.5) / (F32)pow(10, mPrecision);
++251: F32 displayed_value = (F32)floor(getValue().asReal() * pow(10'''''.0''''', mPrecision) + 0.5) / (F32)pow(10'''''.0''''', mPrecision);


*linden\indra\newview\llstartup.cpp @ line 1459
Currently - as of version 1.21 - CMake requires Quicktime to be installed.
--1459: gUTCOffset = (server_utc_time - now);
++1459: gUTCOffset = (server_utc_time - '''''(S32)'''''now);


*linden\indra\newview\llpaneldirevents.cpp @ line 137, and line 169
'''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.
--137: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
* 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]
  ++137: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);
* 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>.


--169: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
(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)
++169: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);


*linden\indra\newview\llfloaterreporter.cpp @ line 668
* Copy the contents of <code>QuicktimeSDK\CIncludes</code> into <code>linden\libraries\i686-win32\include\quicktime</code>.
--668: msg->addU32Fast(_PREHASH_Time, mcd->mTime);
++668: msg->addU32Fast(_PREHASH_Time, '''''(U32)'''''mcd->mTime);


*linden\indra\newview\llfloaterland.cpp @ line 2609, and line 2878
== Building the Viewer ==
--2609: S32 now = time(NULL);
++2609: S32 now = '''''(S32)'''''time(NULL);


--2878: S32 now = time(NULL);
At this point, you should be ready to use [[CMake]] to build the Visual Studio solution for the project.
++2878: S32 now = '''''(S32)'''''time(NULL);


*linden\indra\newview\llfloaterbump.cpp @ line 120
'''NOTE''': CMake is only supported for Viewer versions 1.21 and beyond.
--120: timep = utc_to_pacific_time(mcd->mTime, gPacificDaylightTime);
++120: timep = utc_to_pacific_time('''''(S32)'''''mcd->mTime, gPacificDaylightTime);


*linden\indra\newview\viewer.cpp @ line 2510
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.
--2515: srand(time(NULL));
++2515: srand('''''(U32)'''''time(NULL));
*linden\indra\newview\llurlwhitelist.cpp @ line 43
--43: mUrlListIter ( 0 )
++43: mUrlListIter ( '''''LLUrlWhiteList::mUrlListIter''''' )


==== Misc. Code Editing ====
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.
*linden\indra\llinventory\llinventory.cpp @ line 1433
++1433: @ (S32)now


=== Disable llMozLib ===
From the command line, navigate to the <code>indra</code> folder of your source tree and run:
*linden\indra\llcommon\llpreprocessor.h @ line 51
--51: #define LL_LIBXUL_ENABLED 1
++51: #define LL_LIBXUL_ENABLED '''''0'''''


== Ready, Set, Build! ==
python develop.py
* Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production).
* SecondLife.exe will be built in \indra\newview\ReleaseNoOpt or \indra\newview\ReleaseForDownload
* Create a shortcut to SecondLife.exe, and change the start location to \indra\newview\ (all the .dll will be found there.)


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


If you can't connect once you've built the viewer:
* VisualStudio 2005:


* If you're getting errors while trying to load your inventory, try [[Stuck logging in|clearing your cache and deleting other temporary files]].
python develop.py -G VC80


=== Cannot open include file: 'windows.h' problem ===
* VisualStudio 2008:
If you run into this problem:
 
  ..\..\..\boost/regex/v4/fileiter.hpp(44) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
python develop.py -G VC90
Fix it with this: (thanks Fairlight!)
 
set INCLUDE=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include;%INCLUDE%
'''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.
set LIB=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib;%LIB%
 
=== Finding your build directory ===
 
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>
 
=== Compiling ===
 
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!
 
=== 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 ==
 
* Ask for help on [[IRC]] ([irc://irc.freenode.net/opensl #opensl on freenode])
* Find someone on the [[OpenSource-Dev|OpenSource-Dev mailing list]]
* Fix it: [[Modifying CMake Files‎]] (and please, submit a patch!)
 
Please also see the (user contributed) instructions at [[User:Michelle2_Zenovka/cmake]]
 
[[Category:Compiling viewer]]

Latest revision as of 09: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