Difference between revisions of "Microsoft Windows Builds"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{multi-lang}}
{{multi-lang}}
{{CompileNav}}
{{CompileNav}}  


Philosophy: to keep it brief, this page should only include steps we KNOW ARE NEEDED, not random hints.  Extra details or open issues can go on the talk page.


On Windows, there are several options on build (compile) environment of the Second Life.
{{KBnote|Following this recipe will probably take 6 to 12 hours of wall-clock time, and 2 to 6 hours of your time, if you're starting from a fresh Windows XP/Vista/7 system.}}


This page explains how you can compile the Viewer on Microsoft Windows.
== Establish your programming environment ==


Currently, only 32 bit binary is tested.  There seems to be several trials to produce 64 bit Windows <code>.exe</code> of the Viewer. If you did, please write your experience on [[Talk:Microsoft Windows Builds|the discussion page]] (regardless it was successful or not!)
This is needed for compiling any viewer based on the LL open source code and only needs to be done once.


== Choosing and preparing a compiler ==
=== Install and update Visual Studio and SDKs ===


=== Linden-supported compilers ===
# Install [http://www.microsoft.com/express/download/ Visual Studio 2010] (Express is okay)
#* If you installed VS2010 Express also install [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84&displaylang=en Microsoft Visual C++ 2010 Redistributable Package] or [http://www.microsoft.com/download/en/confirmation.aspx?id=14632 64-bit Windows] version.
# Install  [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=35aeda01-421d-4ba5-b44b-543dc8c33a20 Windows SDK for Windows 7 and .NET Framework 4] (ISO) or [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6B6C21D2-2006-4AFA-9702-529FA782D63B Windows SDK for Windows 7 and .NET Framework 4] (Web Install)
# Install  [http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba DirectX SDK (June 2010)]
# Run [http://www.update.microsoft.com/microsoftupdate/v6 Microsoft Update], and keep running it until no updates are needed. This may take 6~8 iterations on older versions of windows.
#* For Windows Vista and Windows 7, you need to select "Get updates from other Microsoft products" to get the updates for Visual Studio.
#* For Windows XP, use the provided link above.  The Windows Update menu item on your computer is not the correct updater to use.
#* During the update cycles make sure you have picked up Microsoft Visual Studio 2010 Service Pack 1 [http://go.microsoft.com/fwlink/?LinkId=210710 (ISO)] or [http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5 (Web Install)]


Supported compiler: '''Visual Studio .NET 2005 Professional'''
=== Install required development tools ===


You need to setup the compiler and Microsoft Development tools as follows:
{{KBnote|The order of the following installations should not matter.}}
* Setup [[Microsoft Visual Studio]]
{{KBnote|If the installer for a particular package does not update your PATH environment variable you will have to do this manually.}}


=== Community experimental compilers ===
# '''CMake''' ([http://www.cmake.org/HTML/Download.html download CMake])
#* This should be version 2.8.4 (or above in the 2.8.x series).
#*Add the <code>\bin</code> directory to your path.
# '''Python''' (either [http://www.python.org/download/ Standard Python] or [http://www.activestate.com/activepython/downloads ActivePython])
#* Version 2.7.1 works with the build scripts.
# '''Mercurial''' (either [http://tortoisehg.bitbucket.org/ TortoiseHg] or [http://mercurial.selenic.com/ Mercurial Hg])
# '''Cygwin''' ([http://www.cygwin.com/ download Cygwin])
#* When you run the cygwin setup utility make sure you have selected to install '''unzip''' (under "Archives"), '''bison''', '''flex''', '''patchutils''' (all located under "devel"), and '''curl''' (under "Web"), which are not part of the default install. Do not install Cygwin Python or Mercurial.  You won't need to use the Cygwin shell for anything.
#*Add  the <code>cygwin\bin</code> directory to the '''very end''' of your path and make sure it stays that way.


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


* Visual C++ 2005 Express ([[Microsoft Visual Studio|instructions]], but the screenshots for [[Compiling the Viewer (MSVS2008)|VS2008]] are worth a glance too)
# [http://code.google.com/p/unsis/downloads/list Unicode NSIS (Nullsoft Scriptable Install System)]
* Visual Studio 2008 ([[Compiling the Viewer (MSVS2008)|instructions]])
#* This is the package installer used to build <code>Second_Life_<version-code>_LindenDeveloper_Setup.exe</code>. You only need this package if you are going to distribute the viewer you compile or if you want to install it locally.
* Visual C++ 2008 Express ([[Compiling the Viewer (MSVS2008)|instructions]])
#: In the [[#Configuring_the_Viewer|Configure VS2010 step]] below you will need to add a line in the '''Executable Directories''' section:
#:* 64 bit systems use <code>%ProgramFiles(x86)%\NSIS\Unicode</code>
#:* 32 bit systems use <code>%ProgramFiles%\NSIS\Unicode</code>
# [http://notepadplusplus.org/ Notepad++]
#* You need to use an editor that conforms to the [[Coding Standard]]. In particular, you must not check in files with DOS line endings except in very limited circumstances; see [[How to avoid DOS line endings in Windows tools]].


{{KBwarning|Boost support with Visual Studio 2008 is problematic as of this writing. Check {{jira|VWR-9541}} before continuing on this path.}}
=== Install Autobuild ===
* Follow the directions at [[Autobuild#Getting_Autobuild|Getting Autobuild]] to install Autobuild
* Add an environment variable, so that autobuild doesn't default to using (or trying) older compiler versions:
** Right-click "My Computer" and select '''Properties'''.
** When the Properties dialog opens, click the '''Advanced''' tab followed by the '''Environmental Variables''' button. This will open a new window with a list of System and User variables.
** In the User section, click '''New'''. Set '''Variable Name''' to AUTOBUILD_VSVER and set '''Variable Value''' to 100.
** Click the OK/Close buttons to close all the windows.


{{KBcaution|Make sure you install to paths without spaces in it.}}
=== Configure VC2010 ===
While you may choose to use autobuild for all your compiling you still need to establish certain settings internal to VC2010.


== Getting other development tools ==
*Start the IDE


You will need to install the following tools to compile the Viewer:
*Navigate to '''Tools''' > '''Options''' > '''Projects and Solutions''' > '''Build and Run''' and set '''maximum number of parallel projects builds''' to <code>1</code>.
* '''UniCode NSIS''' ([http://code.google.com/p/unsis/downloads/list download Unicode NSIS])
**  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)]


Verify that Cygwin, CMake, and Python are in the windows "PATH".
* (VC Express only) Enable '''Tools''' > '''Settings''' > '''Expert Settings''' to get the '''Build''' (and other) menus.  If you already have a '''Build''' menu you do not need to perform this step.


== Downloading Source Code ==
{{KBnote|The following steps require an open visual studio project.  It does not matter which project you use, as you will only change some global settings used by all projects when they are opened.  The open project itself won't be changed.}}


{{KBcaution|Make sure you install to paths without spaces in it.}}
You need to set a number of paths.  
* Open any existing project you may have or make a New Project.


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]].
At the bottom on the Solution Explorer you will see three tabs.
*Click the one on the right labeled '''Property Manager'''. (The name may be somewhat truncated.)


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.
[[File:VS2010_Property_Manager.PNG|100px]]
[[:File:VS2010_Property_Manager.PNG|Example image]]


'''WARNING:'''
*On the left side click to expand any project and then click again to expand the '''Release''' folder.
* 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...
* 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 <code>sl_1_21_6</code>.
[[File:VS2010_Project_Config.PNG|100px]]
[[:File:VS2010_Project_Config.PNG|Example image]]


== Installing libraries ==
*Right click on '''Microsoft.Cpp.Win32.user'''.


SL Viewer depends on some third party libraries.  Some of them are open source, some others are not.
*Pick '''Properties''' > '''VC++ Directories'''.


=== Open source libraries ===
This is where the build environment is pulled together into a functional VC2010 build system and also where much hand wringing, hair pulling, and fist pounding frustration takes place.


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.
*Set '''Executable Directories''' to:


=== Proprietary libraries ===
$(ExecutablePath)
$(DXSDK_DIR)
$(WindowsSdkDir)\Bin
C:\cygwin\bin
$(SystemRoot)


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.
[[File:32BitExecutableDirectories.png|100px]]
[[:File:32BitExecutableDirectories.png|32 bit Executable Directories example image]]


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.
*Set '''Include Directories''' to:


  rem OLIBS.CMD to build a folder tree for 3rd party libraries and includes
  $(WindowsSdkDir)\Include
md olibs
  $(WindowsSdkDir)\Include\gl
md olibs\linden\
  $(DXSDK_DIR)\Include
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


[[File:32BitIncludeDirectories.png|100px]]
[[:File:32BitIncludeDirectories.png|32 bit Include Directories example image]]


==== Fmod ====
*Set '''Library Directories''' to:
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]. (later versions, like FMOD Ex, are incompatible).
* 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>


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:
$(WindowsSdkDir)\Lib
* Download & extract [http://www.fmod.org/files/fmod3/fmodapi375win.zip FMOD3.75 API for Windows]
$(DXSDK_DIR)
* 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 ====
[[File:32BitLibraryDirectories.png|100px]]
[[:File:32BitLibraryDirectories.png|32 bit Library Directories example image]]


Currently - as of version 1.21 - CMake requires Quicktime to be installed.
== Set up your source code tree ==


'''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.
Plan your directory structure ahead of time.  If you are going to be producing changes or patches you will be cloning a copy of an unaltered source code tree for every change or patch you make, so you might want to have all this work stored in it's own directory.
* 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)
To get a copy of the source code tree:
* Open up a DOS Command window
* CD to where you want to install viewer-development.  Do not have any spaces in this path.
* Do:
hg clone <nowiki>http://hg.secondlife.com/viewer-development</nowiki>


* Copy the contents of <code>QuicktimeSDK\CIncludes</code> into <code>linden\libraries\i686-win32\include\quicktime</code>.
Let's say some time has gone by since you have performed the previous steps and now you want to develop a change or work on a jira.  You will update your clean local repository with all the changes committed to viewer-development since you last synchronized your files:
* CD into <code>viewer-development</code>
* Do:
hg pull -u


== Building the Viewer ==
* Move up one level from <code>viewer-development</code>
* Do:
hg clone viewer-development VWR-nnnnn
Note: <code>nnnnn</code> is the jira number.  You can also clone to a name of your choosing if you are making changes not associated with the LL jira system.


At this point, you should be ready to use [[CMake]] to build the Visual Studio solution for the project.
== Prepare third party libraries ==
Most third party libraries needed to build the viewer will be automatically downloaded for you and installed into the build directory within your source tree during the [[#Configuring_the_Viewer|configuration step]] below. Some few need to be manually set up, though, when using an open source developer configuration (<code>Release'''OS'''</code>, <code>RelWithDebInfo'''OS'''</code> or <code>Debug'''OS'''</code>)


'''NOTE''': CMake is only supported for Viewer versions 1.21 and beyond.
=== Fmod method 1 (using autobuild) ===


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.
CD to where you want to install the 3p-fmod repository and do:
hg clone <nowiki>https://bitbucket.org/lindenlab/3p-fmod</nowiki>


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.
CD into the <code>3p-fmod</code> directory you created and build it:
autobuild build --all


From the command line, navigate to the <code>indra</code> folder of your source tree and run:
Package the results:
autobuild package


  python develop.py
Update autobuild with the filename and hash just displayed. CD to the directory where you cloned viewer-development and do:


CMake will pick the most recent version of Visual Studio we support. If you want to specify the version of Visual Studio to use.
copy autobuild.xml my_autobuild.xml
set AUTOBUILD_CONFIG_FILE=my_autobuild.xml
autobuild installables edit fmod platform=windows hash=<hash> url=file:///<fmod-filespec>


* VisualStudio 2005:
Example:
copy autobuild.xml my_autobuild.xml
autobuild installables edit fmod platform=windows hash=0f196f00e7dff49f22252efb68525658 url=file:///C:/3p-fmod/fmod-3.75-windows-20110531.tar.bz2


python develop.py -G VC80
{{KBnote|Having to copy <code>autobuild.xml</code> and modify the copy from within a cloned repository is a lot of work for every repository you make, but this is the only way to guarantee you pick up upstream changes to <code>autobuild.xml</code> and do not send up a modified <code>autobuild.xml</code> when you do an hg push.}}


* VisualStudio 2008:
=== Fmod method 2 (using switches) ===
[To be written up]


python develop.py -G VC90
== Configuring the Viewer Build ==


'''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.
Fmod is the audio library the viewer uses. If you are compiling with Fmod you will need to do:
set AUTOBUILD_CONFIG_FILE=my_autobuild.xml


=== Finding your build directory ===
At the command line in the source tree's root directory (presumably a directory you have cloned from viewer-development, as it is not a good idea to work in viewer-development, unless you are only compiling for youself) e.g. <code>C:\linden\VWR-12345\</code>) run:
autobuild configure -c [CONFIGURATION]
where <code>[CONFIGURATION]</code> is one of those listed at [[Building the Viewer with Autobuild#Build a desired configuration]] (<code>ReleaseOS</code>, <code>RelWithDebInfoOS</code>, <code>DebugOS</code>)


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:
=== Configuration Switches ===
* VS 2005: <code>indra/build-vc80</code>
There are a number of switches you can use to modify the configuration process. The name of each switch is followed by its type and then by the value you want to set.
* VS 2008: <code>indra/build-vc90</code>


=== Compiling ===
* '''FMOD''' (bool) controls if the Fmod package is incorporated into the viewer.  You must have performed the Fmod installation steps in [[Viewer_2_Microsoft_Windows_Builds#Fmod_method_1_.28using_autobuild.29]] for this to work.
* '''LL_TESTS''' (bool) controls if the tests are compiled and run.  There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
* '''PACKAGE''' (bool) controls if the package step is run.  You must have installed NSIS described in [[Viewer_2_Microsoft_Windows_Builds#Install_optional_development_tools]] for this to work.


To start a build, do one of the following:
{{KBnote|'''OFF''' and '''NO''' are the same as '''FALSE'''; anything else is considered to be '''TRUE'''.}}
*  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? ===
Example:
autobuild configure -c ReleaseOS -- -DLL_TESTS:BOOL=FALSE -DPACKAGE:BOOL=FALSE -DFMOD:BOOL=TRUE


On Windows, the built Viewer ought to run from VS2005.
== Compiling the Viewer ==
=== Compiling the viewer with autobuild ===
You can compile the viewer with either autobuild (the encouraged/supported method) or with the VS IDE.


To run outside MS VS, see Discussion tab:
When compiling with autobuild you will have the best chance of success if you work from within a preconfigured Command Prompt window.  Depending on how your computer has been set up there are two possible ways to open this window and you need to find which works in your particular case:
[[Talk:Microsoft_Windows_Builds#Running_viewer_outside_of_MS_VS]]
*Method 1
**From '''All Programs''' Navigate into the '''Microsoft Windows SDK V7.1''' program menu
**Click on '''Windows SDK 7.1 Command Prompt'''
*Method 2
**From '''All Programs''' Navigate into the '''Microsoft Visual Studio 2010''' program menu
**Click on '''Microsoft Visual Studio Command Prompt (2010)'''


=== Build instructions for 1.20 and earlier ===
{{KBcaution|If you are building with Fmod and have followed the previous Fmod setup instructions AND you are now using a new command window you will need to redo the <code>set AUTOBUILD_CONFIG_FILE{{=}}my_autobuild.xml</code>.}}


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.
*Run:
autobuild build -c [CONFIGURATION] --no-configure


== What to do if it doesn't work for you ==
There are some useful switches to know about, so your commands may look like this:
autobuild configure -c ReleaseOS -- -DLL_TESTS:BOOL=FALSE -DPACKAGE:BOOL=FALSE -DFMOD:BOOL=TRUE
autobuild build -c ReleaseOS --no-configure


* Ask for help on [[IRC]] ([irc://irc.freenode.net/opensl #opensl on freenode])
{{KBnote|It is possible to use autobuild to do both the configure step (only needed once) and the build step with one command.  I find it is clearer and saves a bit of time if these steps are done separately.}}
* 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]]
{{KBnote|Do not be alarmed if you see groups of messages with '''warning LNK4099: PDB''' in them.}}
 
=== Compiling the viewer with the IDE ===
 
The autobuild configure step created the <code>\build-vc100</code> directory at the root of the source tree.  In here is the <code>SecondLife.sln</code> solution file.
 
Start the IDE and open this solution.
 
You might want to change the build type in the drop-down located in the toolbar from '''Debug''' to '''Release''' or '''RelWithDebInfo'''.
 
[[File:VS2010BuildType.png|100px]]
[[:File:VS2010BuildType.png|Changing build type example image]]
 
You need to adjust the Platform Toolset setting.
* Select all the projects in the Solution Explorer list on the left of the screen.
** Click on the first project and scroll to the bottom of this list and {{K|shift}}-click on the last project.
* Right click on the selected list
* Navigate to '''Properties''' > '''Configuration Properties''' > '''General''' > '''Platform Toolset'''
* Change this value to <code>Windows7.1SDK</code>
 
* Push {{K|F7}} to start the compiler.
 
== Running your newly built viewer ==
=== Running from a desktop shortcut ===
* Make a desktop shortcut for <code>Drive:\your-path\build-vc100\newview\Release\secondlife-bin.exe</code>
 
* Right-click the shortcut
* Select '''Properties'''
* Set '''Start in:''' to <code>Drive:\your-path\indra\newview</code>
 
=== Running from within the IDE ===
* In the Solution Explorer pane right click on '''secondlife-bin'''
** Click '''Set as StartUp Project'''
** Pick '''Properties''' > '''Configuration Properties''' > '''Debugging'''
*** Set '''Command''' to <code>Drive:\your-path\build-vc100\newview\Release\secondlife-bin.exe</code>
*** Set '''Working Directory''' to <code>..\..\indra\newview</code>
 
== Handling Problems ==
 
If you encounter errors or run into problems following the instructions above, please first check whether someone else already had the same issue. A solution might be known already. See the [[#Common_Issues.2FBugs.2FGlitches_And_Solutions|issue list below]], check [[{{TALKPAGENAME}}|the talk page]] (and report useful experiences there) and search our [[issue tracker]]. Even when no description of your problem has been written down yet, someone might know about it, so get in touch with the community to [[#Getting_help|get help]].
 
=== Getting help ===
* Subscribe to [[OpenSource-Dev|OpenSource-Dev Mailing List]] ([https://lists.secondlife.com/cgi-bin/mailman/listinfo/opensource-dev subscribe]) and post your question there.
* For faster response, join the general open source viewer discussion and development [[IRC]] channel [irc://irc.freenode.org/opensl #opensl on freenode].  Hopefully a helpful person is online when you ask your question.
 
=== Common Issues/Bugs/Glitches And Solutions ===
 
==== Not being able to find objidl.h in the Microsoft Windows SDK, when compiling llwindow ====
https://lists.secondlife.com/pipermail/opensource-dev/2011-April/006562.html
* Can be caused by path problems or some installation conflicts with the DirectX SDK.
 
==== stdint.h typedef conflicts between Quicktime and VS2010 ====
https://lists.secondlife.com/pipermail/opensource-dev/2011-April/006565.html
*: Can be solved by some small edits to header files to make sure the two don't bash on each other.
 
==== Eliminate depreciated switches messages and use memory more efficiently ====
 
The VS2010 compiler uses a lot of memory while compiling the viewer.  If you run out of memory you will start to page heavily and your compile time will become much longer.  The /Zm1000 switch affects compiler memory usage.
 
You may see this message while compiling:
use 'EHsc' instead of 'GX'
 
Here is how to free up some memory the compiler allocates and to eliminate these messages:
 
*Edit <code>\CMake 2.8\share\cmake-2.8\Modules\Platform\Windows-cl.cmake</code>
 
*Replace line 156 with:
  IF(MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
  ELSEIF(NOT MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR")
  ENDIF(MSVC10)
 
*Replace line 172 with: 
  IF(MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
  ELSEIF(NOT MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR")
  ENDIF(MSVC10)
 
*Replace line 184 with:
  IF(MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
  ELSEIF(NOT MSVC10)
    SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR")
  ENDIF(MSVC10)
 
== References ==
 
Tip of the hat to Nicky_Perian for [[User:Nicky_Perian/Visual_Studio_10_Autobuild]]


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

Revision as of 17:02, 17 August 2011

Philosophy: to keep it brief, this page should only include steps we KNOW ARE NEEDED, not random hints. Extra details or open issues can go on the talk page.

KBnote.png Note: Following this recipe will probably take 6 to 12 hours of wall-clock time, and 2 to 6 hours of your time, if you're starting from a fresh Windows XP/Vista/7 system.

Establish your programming environment

This is needed for compiling any viewer based on the LL open source code and only needs to be done once.

Install and update Visual Studio and SDKs

  1. Install Visual Studio 2010 (Express is okay)
  2. Install Windows SDK for Windows 7 and .NET Framework 4 (ISO) or Windows SDK for Windows 7 and .NET Framework 4 (Web Install)
  3. Install DirectX SDK (June 2010)
  4. Run Microsoft Update, and keep running it until no updates are needed. This may take 6~8 iterations on older versions of windows.
    • For Windows Vista and Windows 7, you need to select "Get updates from other Microsoft products" to get the updates for Visual Studio.
    • For Windows XP, use the provided link above. The Windows Update menu item on your computer is not the correct updater to use.
    • During the update cycles make sure you have picked up Microsoft Visual Studio 2010 Service Pack 1 (ISO) or (Web Install)

Install required development tools

KBnote.png Note: The order of the following installations should not matter.
KBnote.png Note: If the installer for a particular package does not update your PATH environment variable you will have to do this manually.
  1. CMake (download CMake)
    • This should be version 2.8.4 (or above in the 2.8.x series).
    • Add the \bin directory to your path.
  2. Python (either Standard Python or ActivePython)
    • Version 2.7.1 works with the build scripts.
  3. Mercurial (either TortoiseHg or Mercurial Hg)
  4. Cygwin (download Cygwin)
    • When you run the cygwin setup utility make sure you have selected to install unzip (under "Archives"), bison, flex, patchutils (all located under "devel"), and curl (under "Web"), which are not part of the default install. Do not install Cygwin Python or Mercurial. You won't need to use the Cygwin shell for anything.
    • Add the cygwin\bin directory to the very end of your path and make sure it stays that way.

Install optional development tools

  1. Unicode NSIS (Nullsoft Scriptable Install System)
    • This is the package installer used to build Second_Life_<version-code>_LindenDeveloper_Setup.exe. You only need this package if you are going to distribute the viewer you compile or if you want to install it locally.
    In the Configure VS2010 step below you will need to add a line in the Executable Directories section:
    • 64 bit systems use %ProgramFiles(x86)%\NSIS\Unicode
    • 32 bit systems use %ProgramFiles%\NSIS\Unicode
  2. Notepad++

Install Autobuild

  • Follow the directions at Getting Autobuild to install Autobuild
  • Add an environment variable, so that autobuild doesn't default to using (or trying) older compiler versions:
    • Right-click "My Computer" and select Properties.
    • When the Properties dialog opens, click the Advanced tab followed by the Environmental Variables button. This will open a new window with a list of System and User variables.
    • In the User section, click New. Set Variable Name to AUTOBUILD_VSVER and set Variable Value to 100.
    • Click the OK/Close buttons to close all the windows.

Configure VC2010

While you may choose to use autobuild for all your compiling you still need to establish certain settings internal to VC2010.

  • Start the IDE
  • Navigate to Tools > Options > Projects and Solutions > Build and Run and set maximum number of parallel projects builds to 1.
  • (VC Express only) Enable Tools > Settings > Expert Settings to get the Build (and other) menus. If you already have a Build menu you do not need to perform this step.
KBnote.png Note: The following steps require an open visual studio project. It does not matter which project you use, as you will only change some global settings used by all projects when they are opened. The open project itself won't be changed.

You need to set a number of paths.

  • Open any existing project you may have or make a New Project.

At the bottom on the Solution Explorer you will see three tabs.

  • Click the one on the right labeled Property Manager. (The name may be somewhat truncated.)

VS2010 Property Manager.PNG Example image

  • On the left side click to expand any project and then click again to expand the Release folder.

VS2010 Project Config.PNG Example image

  • Right click on Microsoft.Cpp.Win32.user.
  • Pick Properties > VC++ Directories.

This is where the build environment is pulled together into a functional VC2010 build system and also where much hand wringing, hair pulling, and fist pounding frustration takes place.

  • Set Executable Directories to:
$(ExecutablePath)
$(DXSDK_DIR)
$(WindowsSdkDir)\Bin
C:\cygwin\bin
$(SystemRoot)

32BitExecutableDirectories.png 32 bit Executable Directories example image

  • Set Include Directories to:
$(WindowsSdkDir)\Include
$(WindowsSdkDir)\Include\gl
$(DXSDK_DIR)\Include

32BitIncludeDirectories.png 32 bit Include Directories example image

  • Set Library Directories to:
$(WindowsSdkDir)\Lib
$(DXSDK_DIR)

32BitLibraryDirectories.png 32 bit Library Directories example image

Set up your source code tree

Plan your directory structure ahead of time. If you are going to be producing changes or patches you will be cloning a copy of an unaltered source code tree for every change or patch you make, so you might want to have all this work stored in it's own directory.

To get a copy of the source code tree:

  • Open up a DOS Command window
  • CD to where you want to install viewer-development. Do not have any spaces in this path.
  • Do:
hg clone http://hg.secondlife.com/viewer-development

Let's say some time has gone by since you have performed the previous steps and now you want to develop a change or work on a jira. You will update your clean local repository with all the changes committed to viewer-development since you last synchronized your files:

  • CD into viewer-development
  • Do:
hg pull -u
  • Move up one level from viewer-development
  • Do:
hg clone viewer-development VWR-nnnnn

Note: nnnnn is the jira number. You can also clone to a name of your choosing if you are making changes not associated with the LL jira system.

Prepare third party libraries

Most third party libraries needed to build the viewer will be automatically downloaded for you and installed into the build directory within your source tree during the configuration step below. Some few need to be manually set up, though, when using an open source developer configuration (ReleaseOS, RelWithDebInfoOS or DebugOS)

Fmod method 1 (using autobuild)

CD to where you want to install the 3p-fmod repository and do:

hg clone https://bitbucket.org/lindenlab/3p-fmod

CD into the 3p-fmod directory you created and build it:

autobuild build --all

Package the results:

autobuild package 

Update autobuild with the filename and hash just displayed. CD to the directory where you cloned viewer-development and do:

copy autobuild.xml my_autobuild.xml
set AUTOBUILD_CONFIG_FILE=my_autobuild.xml
autobuild installables edit fmod platform=windows hash=<hash> url=file:///<fmod-filespec>

Example:

copy autobuild.xml my_autobuild.xml
autobuild installables edit fmod platform=windows hash=0f196f00e7dff49f22252efb68525658 url=file:///C:/3p-fmod/fmod-3.75-windows-20110531.tar.bz2
KBnote.png Note: Having to copy autobuild.xml and modify the copy from within a cloned repository is a lot of work for every repository you make, but this is the only way to guarantee you pick up upstream changes to autobuild.xml and do not send up a modified autobuild.xml when you do an hg push.

Fmod method 2 (using switches)

[To be written up]

Configuring the Viewer Build

Fmod is the audio library the viewer uses. If you are compiling with Fmod you will need to do:

set AUTOBUILD_CONFIG_FILE=my_autobuild.xml

At the command line in the source tree's root directory (presumably a directory you have cloned from viewer-development, as it is not a good idea to work in viewer-development, unless you are only compiling for youself) e.g. C:\linden\VWR-12345\) run:

autobuild configure -c [CONFIGURATION]

where [CONFIGURATION] is one of those listed at Building the Viewer with Autobuild#Build a desired configuration (ReleaseOS, RelWithDebInfoOS, DebugOS)

Configuration Switches

There are a number of switches you can use to modify the configuration process. The name of each switch is followed by its type and then by the value you want to set.

KBnote.png Note: OFF and NO are the same as FALSE; anything else is considered to be TRUE.

Example:

autobuild configure -c ReleaseOS -- -DLL_TESTS:BOOL=FALSE -DPACKAGE:BOOL=FALSE -DFMOD:BOOL=TRUE

Compiling the Viewer

Compiling the viewer with autobuild

You can compile the viewer with either autobuild (the encouraged/supported method) or with the VS IDE.

When compiling with autobuild you will have the best chance of success if you work from within a preconfigured Command Prompt window. Depending on how your computer has been set up there are two possible ways to open this window and you need to find which works in your particular case:

  • Method 1
    • From All Programs Navigate into the Microsoft Windows SDK V7.1 program menu
    • Click on Windows SDK 7.1 Command Prompt
  • Method 2
    • From All Programs Navigate into the Microsoft Visual Studio 2010 program menu
    • Click on Microsoft Visual Studio Command Prompt (2010)
KBcaution.png Important: If you are building with Fmod and have followed the previous Fmod setup instructions AND you are now using a new command window you will need to redo the set AUTOBUILD_CONFIG_FILE=my_autobuild.xml.
  • Run:
autobuild build -c [CONFIGURATION] --no-configure

There are some useful switches to know about, so your commands may look like this:

autobuild configure -c ReleaseOS -- -DLL_TESTS:BOOL=FALSE -DPACKAGE:BOOL=FALSE -DFMOD:BOOL=TRUE
autobuild build -c ReleaseOS --no-configure
KBnote.png Note: It is possible to use autobuild to do both the configure step (only needed once) and the build step with one command. I find it is clearer and saves a bit of time if these steps are done separately.
KBnote.png Note: Do not be alarmed if you see groups of messages with warning LNK4099: PDB in them.

Compiling the viewer with the IDE

The autobuild configure step created the \build-vc100 directory at the root of the source tree. In here is the SecondLife.sln solution file.

Start the IDE and open this solution.

You might want to change the build type in the drop-down located in the toolbar from Debug to Release or RelWithDebInfo.

VS2010BuildType.png Changing build type example image

You need to adjust the Platform Toolset setting.

  • Select all the projects in the Solution Explorer list on the left of the screen.
    • Click on the first project and scroll to the bottom of this list and Shift ⇧-click on the last project.
  • Right click on the selected list
  • Navigate to Properties > Configuration Properties > General > Platform Toolset
  • Change this value to Windows7.1SDK
  • Push F7 to start the compiler.

Running your newly built viewer

Running from a desktop shortcut

  • Make a desktop shortcut for Drive:\your-path\build-vc100\newview\Release\secondlife-bin.exe
  • Right-click the shortcut
  • Select Properties
  • Set Start in: to Drive:\your-path\indra\newview

Running from within the IDE

  • In the Solution Explorer pane right click on secondlife-bin
    • Click Set as StartUp Project
    • Pick Properties > Configuration Properties > Debugging
      • Set Command to Drive:\your-path\build-vc100\newview\Release\secondlife-bin.exe
      • Set Working Directory to ..\..\indra\newview

Handling Problems

If you encounter errors or run into problems following the instructions above, please first check whether someone else already had the same issue. A solution might be known already. See the issue list below, check the talk page (and report useful experiences there) and search our issue tracker. Even when no description of your problem has been written down yet, someone might know about it, so get in touch with the community to get help.

Getting help

Common Issues/Bugs/Glitches And Solutions

Not being able to find objidl.h in the Microsoft Windows SDK, when compiling llwindow

https://lists.secondlife.com/pipermail/opensource-dev/2011-April/006562.html

  • Can be caused by path problems or some installation conflicts with the DirectX SDK.

stdint.h typedef conflicts between Quicktime and VS2010

https://lists.secondlife.com/pipermail/opensource-dev/2011-April/006565.html

  • Can be solved by some small edits to header files to make sure the two don't bash on each other.

Eliminate depreciated switches messages and use memory more efficiently

The VS2010 compiler uses a lot of memory while compiling the viewer. If you run out of memory you will start to page heavily and your compile time will become much longer. The /Zm1000 switch affects compiler memory usage.

You may see this message while compiling:

use 'EHsc' instead of 'GX'

Here is how to free up some memory the compiler allocates and to eliminate these messages:

  • Edit \CMake 2.8\share\cmake-2.8\Modules\Platform\Windows-cl.cmake
  • Replace line 156 with:
 IF(MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
 ELSEIF(NOT MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR")
 ENDIF(MSVC10)
  • Replace line 172 with:
 IF(MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
 ELSEIF(NOT MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR")
 ENDIF(MSVC10)
  • Replace line 184 with:
 IF(MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /EHsc /GR")
 ELSEIF(NOT MSVC10)
   SET(CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR")
 ENDIF(MSVC10)

References

Tip of the hat to Nicky_Perian for User:Nicky_Perian/Visual_Studio_10_Autobuild