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

From Second Life Wiki
Jump to navigation Jump to search
(Removed source edits for older releases, and reorganized entirely...)
Line 1: Line 1:
{{CompileNav}}
{{CompileNav}}


This page explains how you can compile the viewer on Microsoft Windows using Visual Studio 2005 or Visual C++ Express 2005.
This page explains how you can compile the viewer on Microsoft Windows using Visual Studio 2005 or Visual C++ Express 2005.  If you are using Visual Studio 2003, you should read [[Compiling the viewer (MSVS2003)|another page]].  Note that Lindens are using VS2003, and you will get less trouble with it than with VS2005.  


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 source code where typecasts were lazily handled before, as they cause errors now. You will also find some POSIX names deprecated and replaced by ISO C++ standards. Be sure to refer to the other [[Compiling the viewer (MSVS2003)|compilation steps with the 2003 version]] for more help.
The following explanation is for Viewer release 1.14.0.0 or later. See an [[https://wiki.secondlife.com/w/index.php?title=Compiling_the_viewer_%28MSVS2005%29&oldid=16565 older version of this page]] for the Viewer releases before Mar. 2007.


== Prerequisites ==
== Development Environment ==
 
You need to setup the compiler and Microsoft Development tools as follows:
* Visual Studio 2005 '''''-or-''''' [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 Express]<small>(Free)</small>
* Visual Studio 2005 '''''-or-''''' [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 Express]<small>(Free)</small>
** [http://www.microsoft.com/downloads/details.aspx?familyid=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en Microsoft Platform SDK]
* [http://www.microsoft.com/downloads/details.aspx?familyid=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en Microsoft Platform SDK]
** 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)]
* 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)]
*** 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.
: '''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.
** Set up the project globals:
* Set up the project globals:
*** Start Microsoft Visual Studio 2005
** Start Microsoft Visual Studio 2005
*** Go to Tools/Options/Projects/VC++ Directories
** 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.
** 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'''.
** If the DirectX SDK paths aren't present, add them to both '''includes''' and '''libraries'''.
*** Note: The newest DirectX SDK ("December 2006") lib folder has two sub-folders, x64 and x86.  Make sure your path goes to one of them, rather than the lib folder itself, or you will get a Link error.
*: Note: The newest DirectX SDK ("December 2006") lib folder has two sub-folders, x64 and x86.  Make sure your path goes to one of them, rather than the lib folder itself, or you will get a Link error.
 
You will also need some open source development tools.
* [http://www.activestate.com/Products/ActivePython/?mp=1 AcrivePython 2.3x]
* [http://www.activestate.com/Products/ActivePerl/?mp=1 ActivePerl]
* [http://www.cygwin.com/ Cygwin]
* [http://www.cygwin.com/ Cygwin]
** When you run the cygwin setup utility make sure you have selected to install patchutils, flex, and bison (all located under "devel") which are not part of the default install. 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.
** When you run the cygwin setup utility make sure you have selected to install patchutils, flex, and bison (all located under "devel") which are not part of the default install. 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.


== Source Files ==
== Source Files ==
You can download the Viewer source codes on official [[source downloads]] page.  You can also use some version controlled repository run by the community.  (See [[Get source and compile#Getting the source]]).


'''WARNING:'''
'''WARNING:'''
* If the path you unzip the SL source to has a space in it, the batch file that copies message_template.msg will fail. So, if you unzip it to C:\Projects\Dir with space in name\Etc\linden, it won't work!
* If the path you unzip the SL source to has a space in it, the batch file that copies message_template.msg will fail. So, if you unzip it to 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 Visual Studio puts some as a default...
* You should also avoid using non-ASCII (national) characters in the paths, although some localized versions of the tool puts some as a default...
* Unzip your source tree into a directory that has as short full pathname as possible, since long paths cause some unexpected trouble during the build.
* Unzip your source tree into a directory that has as short full pathname as possible, since long paths cause some unexpected trouble during the build.
* At a minimum, grab the source package and the artwork package.  Many of the libraries can either be compiled from source or downloaded from other sites, but it's easiest to also grab the provided library package.
* At a minimum, grab the source package and the artwork package.  Many of the libraries can either be compiled from source or downloaded from other sites, but it's easiest to also grab the provided library package.
Line 29: Line 37:
== Libraries ==
== Libraries ==


Download the library directory from LL, extract it, and copy the files into your SL viewer source code directory, maintaining the same directory structure. Included 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:
SL Viewer depends on some third party libraries.  Some of them are open source, some others are not.
 
=== Open Source Libraries ===
 
You can download the pre-build open source libraries from LL.  They are available on [[source downloads]] page.  Unzip them into your SL viewer source code directory, maintaining the same directory structure.
 
Alternatively, it may be possible to get the source files for the libraries and build by yourself.  See [[Compiling the viewer libraries (MSVS 2003)|the instruction for VS2003 users]] if you try it.  Please note, however, it is not known that VS2005 can successfully compile the libraries.  '''You have been warned.'''


=== Fmod ===
=== Proprietary Libraries ===
 
Lindens does not inlcude the following proprietary libraries.  You will need to follow the instructions to acquire below:
 
==== Fmod ====
* Download & extract [http://www.fmod.org/ifmoddownload.html fmod 3.75 api for win32].
* 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.h" to "linden\libraries\include"
Line 39: Line 57:
* Copy "fmodapi375win\api\fmod.dll" to "linden\indra\newview"
* Copy "fmodapi375win\api\fmod.dll" to "linden\indra\newview"


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


=== Quicktime ===
==== Quicktime ====
* Download & install the [http://developer.apple.com/quicktime/download/ Quicktime SDK for Windows]
* Download & install the [http://developer.apple.com/quicktime/download/ Quicktime SDK for Windows]
* Copy "QuicktimeSDK\Libraries\QTMLClient.lib" to "linden\libraries\i686-win32\lib_release".
* Copy "QuicktimeSDK\Libraries\QTMLClient.lib" to "linden\libraries\i686-win32\lib_release".
Line 49: Line 68:
* Copy the contents of "QuicktimeSDK\CIncludes" into "linden\libraries\i686-win32\include\quicktime".
* Copy the contents of "QuicktimeSDK\CIncludes" into "linden\libraries\i686-win32\include\quicktime".


=== Boost++ ===
Note that you can avoid using QuickTime if you want to do so.  See [[below (MSVS2005)|below]] for details.
'''Note:''' This step should not be needed in recent releases (after mid. March 2007?)


Update boost from vc71 to vc80:
== First Steps ==
* [http://www.boost-consulting.com/download.html Download & install Boost++]  (Pick "Visual C++ 8.0" & "Multithread, static runtime")
* Delete "linden\libraries\include\boost"
* Copy "%programfiles%\boost\boost_1_33_1\boost" to "linden\libraries\include\boost"
* 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"
* Open the file "linden\indra\newview\newview.vcproj" (''newview'' project) in Visual Studio 2005
* Right click on ''newview'' in the Solution Explorer tree 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''
* Do the same thing for the ''test'' project in "linden\indra\test\test.vcproj"
 
=== unistd.h (Express only) ===
* Create an empty file "linden\libraries\include\unistd.h"
 
* Done!


== First Steps ==
=== Environment Setup ===
=== Environment Setup ===
* Open the \indra\indra_complete\indra_complete.sln solution in Visual Studio 2005.
* 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;_USE_32BIT_TIME_T''"
:#[[: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 ===
==== Version: slviewer-src-20070108c ====
Use CTRL+G to help find these lines and edit them, likewise:
*In linden\indra\llcommon\llstringtable.h @ line 103
--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
++#if LL_WINDOWS
++# if (_MSC_VER >= 1400)
++#  pragma warning(disable : 4996)
++# endif
++#endif
*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
--1200: exception_faces |= (1 << i);
++1200: exception_faces |= ((U64)1 << i);
*linden\indra\llui\llsliderctrl.cpp @ line 218
--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
--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
--1459: gUTCOffset = (server_utc_time - now);
++1459: gUTCOffset = (server_utc_time - '''''(S32)'''''now);
*linden\indra\newview\llpaneldirevents.cpp @ line 137, and line 169
--137: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
++137: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);
--169: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
++169: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);
*linden\indra\newview\llfloaterreporter.cpp @ line 668
--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
--2609: S32 now = time(NULL);
++2609: S32 now = '''''(S32)'''''time(NULL);
--2878: S32 now = time(NULL);
++2878: S32 now = '''''(S32)'''''time(NULL);
*linden\indra\newview\llfloaterbump.cpp @ line 120
--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
--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 ====
Use CTRL+G to help find these lines and edit them, likewise:
*In linden\indra\llcommon\llstringtable.h @ line 103
--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
++#if LL_WINDOWS
++# if (_MSC_VER >= 1400)
++#  pragma warning(disable : 4996)
++# endif
++#endif


*In linden\indra\llcommon\u64.cpp @ line 36
Lindens use VS2003 to develop the viewerYou need to convert ''solution file'' and ''project files'' from VS2003 format to VS2005 format.  You also need to modify project files to work around the incompatibility between VS2003 and VS2005.
  --36: char *aptr = strpbrk(str,"0123456789");
++36: '''''const''''' char *aptr = strpbrk(str,"0123456789");


*linden\indra\llprimitive\llprimitive.cpp @ line 1200
'''Note''': linden\indra\indra_complete_vs8.sln is a solution file intended for the Visual Studio 2005, but it '''doesn't work''' (at least in 1.14.0.1 distribution.You need to convert from 2003 version by yourself.
--1200: exception_faces |= (1 << i);
  ++1200: exception_faces |= ((U64)1 << i);


*linden\indra\llui\llsliderctrl.cpp @ line 218
* Start Visual Studio 2005 (or VC++ Express).
  --218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10, mPrecision) + 0.5) / pow(10, mPrecision));
* Use "File > Open > Project/Solution" to open the linden\indra\indra_complete\indra_complete.sln
++218: F32 displayed_value = (F32)(floor(getValueF32() * pow(10'''''.0''''', mPrecision) + 0.5) / pow(10'''''.0''''', mPrecision));
* 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.
* Right click newview in the frame Solution Explorer and click "Set as StartUp Project".
* Pick '''ReleaseNoOpt''' in the Solution Configurations drop-down box beside the green arrow under the tool bar, and do the followings on the Solution Explorer frame:
*#Select all projects, i.e., llaudio, llcharacter, ..., win_updater, '''except''' for lscript_compile_fb and test.  (You can do it by control-clicking on the projects.) Then, right click on the selection and choose Properties.
*#On the Property Pages dialog box, under the Configuration Properties > C/C++ > General, change '''Treat Warnings As Errors''' to "'''No'''". ([[:Image:MSVS2005_Project_Property_Pages_Config_CPP_General.JPG|'''screen shot''']])
*#Under the Configuration Properties > C/C++ > Language, change '''Treat wchar_t as Build-in Type''' to "'''No (/Zc:wchar_t-)'''" ([[:Image:MSVS2005 Project Property Pages Config CPP Language.JPG|'''screen shot''']]).
*#Click '''OK'''.
*#Click '''newview''' to select it alone.  Right click on it again and choose Properties.  Under Configuration Properties > Linker > Input, click '''Additional Dependencies''' on the right to show a button labeled "'''...'''" on it at the very right on the line, then click the '''...''' button.  Scroll down the list to find '''libboost_regex-vc71-mt-s.lib'''.  Rewrite it to libboost_regex-vc'''80'''-mt-s.lib.  Click '''OK''' to close the "Additional Dependencies" dialog, then click OK again to close the "newview Property Pages" dialog box.
*#Do the same thing for '''test'''.
*#Now, the tough part.  Do the following for all projects in the solution except for lscript_compile_fb, one project at a time:
*#*Right click on a project and choose Properties
*#*Under Configuration Properties > C/C++ > PreProcessor, append "'';_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T''" at the end of the '''Preprocessor Definitions'''.([[:Image:MSVS2005 Project Property Pages Config CPP Preprocessor.JPG |'''screen shot''']])
*#*Click OK.
* Pick '''ReleaseForDownload''' in the Solution COnfigurations drop-down box.  Do the same thing (as 1 to 7 above) again.


*linden\indra\llui\llspinctrl.cpp @ line 251
Congratulations! You've converted ''solution file'' and ''project files''.
  --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
'''NOTE:''' You need to do this by hand everytime a new viewer version is released...
--1459: gUTCOffset = (server_utc_time - now);
++1459: gUTCOffset = (server_utc_time - '''''(S32)'''''now);


*linden\indra\newview\llpaneldirevents.cpp @ line 137, and line 169
=== Workarounds ===
--137: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
++137: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);


  --169: internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
There are more compatibility problems between VS2003 and VS2005. You need the following code edits.
++169: internal_time = utc_to_pacific_time('''''(S32)'''''utc_time, gPacificDaylightTime);


*linden\indra\newview\llfloaterreporter.cpp @ line 668
==== unistd.h (Express only) ====
--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
* If you are using Visual C++ Express, create an empty file at "linden\libraries\include\unistd.h"
--2609: S32 now = time(NULL);
* This should not be needed if you are using Visual Studio.
++2609: S32 now = '''''(S32)'''''time(NULL);


--2878: S32 now = time(NULL);
==== Disable llMozLib ====
++2878: S32 now = '''''(S32)'''''time(NULL);


*linden\indra\newview\llfloaterbump.cpp @ line 120
LL supplied pre-compiled llMozLib requires C++ class library come with VS2003You can't link it with VS2005 class library. Workaround is to disable it as follows:
  --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 2515
*linden\indra\llcommon\llpreprocessor.h @ line 51 (two lines below '''#elif LL_WINDOWS''')
--2593: srand(time(NULL));
++2593: srand('''''(U32)'''''time(NULL));
*linden\indra\newview\llurlwhitelist.cpp @ line 43
--43: mUrlListIter ( 0 )
++43: mUrlListIter ( '''''LLUrlWhiteList::mUrlListIter''''' )
 
==== Misc. Code Editing ====
*linden\indra\llinventory\llinventory.cpp @ line 1433
++1433: @ (S32)now
 
=== Disable llMozLib ===
*linden\indra\llcommon\llpreprocessor.h @ line 51
  --51: #define LL_LIBXUL_ENABLED 1
  --51: #define LL_LIBXUL_ENABLED 1
  ++51: #define LL_LIBXUL_ENABLED '''''0'''''
  ++51: #define LL_LIBXUL_ENABLED '''''0'''''


==== Versions: slviewer-src-(20070117a, 1.13.2.12 & 1.13.3.2) ====
==== Ignore test project ====
Use CTRL+G to help find these lines and edit them, likewise:


*In linden\indra\llcommon\llstringtable.h @ line 103
For whatever reason, the '''test''' project doesn't work under VS2005.  Workaround is to disable it as follows:
--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
*Right click on the '''test''' and choose '''Unload Project'''.
++#if LL_WINDOWS
++# if (_MSC_VER >= 1400)
++#  pragma warning(disable : 4996)
++# endif
++#endif


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


*linden\indra\llprimitive\llprimitive.cpp @ line 1200
*See {{JIRA|VWR-426}} if you have recent Windows SDK.
--1200: exception_faces |= (1 << i);
++1200: exception_faces |= ((U64)1 << i);


*linden\indra\llui\llsliderctrl.cpp @ line 218
== Ready, Set, Build! ==
--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
--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\llurlwhitelist.cpp @ line 43
--43: mUrlListIter ( 0 )
++43: mUrlListIter ( '''''LLUrlWhiteList::mUrlListIter''''' )


=== Disable llMozLib ===
*linden\indra\llcommon\llpreprocessor.h @ line 51
--51: #define LL_LIBXUL_ENABLED 1
++51: #define LL_LIBXUL_ENABLED '''''0'''''
== Ready, Set, Build! ==
* Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production).
* Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production).
* SecondLife.exe will be built in \indra\newview\ReleaseNoOpt or \indra\newview\ReleaseForDownload
* SecondLife.exe will be built in linden\indra\newview\ReleaseNoOpt or linden\indra\newview\ReleaseForDownload
* Create a shortcut to SecondLife.exe, and change the start location to \indra\newview\ (all the .dll will be found there.)
* Create a shortcut to SecondLife.exe, and change the start location to linden\indra\newview\ (all the .dll will be found there.)


=== Problems Running? ===
=== Problems Running? ===

Revision as of 08:24, 18 April 2007

This page explains how you can compile the viewer on Microsoft Windows using Visual Studio 2005 or Visual C++ Express 2005. If you are using Visual Studio 2003, you should read another page. Note that Lindens are using VS2003, and you will get less trouble with it than with VS2005.

The following explanation is for Viewer release 1.14.0.0 or later. See an [older version of this page] for the Viewer releases before Mar. 2007.

Development Environment

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

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.
  • Set up the project globals:
    • Start Microsoft Visual Studio 2005
    • Go to Tools > Options > Projects > VC++ Directories
    • Make sure that the includes (screen shot) and libraries (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.
    Note: The newest DirectX SDK ("December 2006") lib folder has two sub-folders, x64 and x86. Make sure your path goes to one of them, rather than the lib folder itself, or you will get a Link error.

You will also need some open source development tools.

  • AcrivePython 2.3x
  • ActivePerl
  • Cygwin
    • When you run the cygwin setup utility make sure you have selected to install patchutils, flex, and bison (all located under "devel") which are not part of the default install. 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.

Source Files

You can download the Viewer source codes on official source downloads page. You can also use some version controlled repository run by the community. (See Get source and compile#Getting the source).

WARNING:

  • If the path you unzip the SL source to has a space in it, the batch file that copies message_template.msg will fail. So, if you unzip it to 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 your source tree into a directory that has as short full pathname as possible, since long paths cause some unexpected trouble during the build.
  • At a minimum, grab the source package and the artwork package. Many of the libraries can either be compiled from source or downloaded from other sites, but it's easiest to also grab the provided library package.

Libraries

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

Open Source Libraries

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

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

Proprietary Libraries

Lindens does not inlcude the following proprietary libraries. You will need to follow the instructions to acquire below:

Fmod

  • Download & extract 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"

OpenGL

Quicktime

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

Note that you can avoid using QuickTime if you want to do so. See below for details.

First Steps

Environment Setup

Lindens use VS2003 to develop the viewer. You need to convert solution file and project files from VS2003 format to VS2005 format. You also need to modify project files to work around the incompatibility between VS2003 and VS2005.

Note: linden\indra\indra_complete_vs8.sln is a solution file intended for the Visual Studio 2005, but it doesn't work (at least in 1.14.0.1 distribution.) You need to convert from 2003 version by yourself.

  • Start Visual Studio 2005 (or VC++ Express).
  • Use "File > Open > Project/Solution" to open the linden\indra\indra_complete\indra_complete.sln
  • 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.
  • Right click newview in the frame Solution Explorer and click "Set as StartUp Project".
  • Pick ReleaseNoOpt in the Solution Configurations drop-down box beside the green arrow under the tool bar, and do the followings on the Solution Explorer frame:
    1. Select all projects, i.e., llaudio, llcharacter, ..., win_updater, except for lscript_compile_fb and test. (You can do it by control-clicking on the projects.) Then, right click on the selection and choose Properties.
    2. On the Property Pages dialog box, under the Configuration Properties > C/C++ > General, change Treat Warnings As Errors to "No". (screen shot)
    3. Under the Configuration Properties > C/C++ > Language, change Treat wchar_t as Build-in Type to "No (/Zc:wchar_t-)" (screen shot).
    4. Click OK.
    5. Click newview to select it alone. Right click on it again and choose Properties. Under Configuration Properties > Linker > Input, click Additional Dependencies on the right to show a button labeled "..." on it at the very right on the line, then click the ... button. Scroll down the list to find libboost_regex-vc71-mt-s.lib. Rewrite it to libboost_regex-vc80-mt-s.lib. Click OK to close the "Additional Dependencies" dialog, then click OK again to close the "newview Property Pages" dialog box.
    6. Do the same thing for test.
    7. Now, the tough part. Do the following for all projects in the solution except for lscript_compile_fb, one project at a time:
      • Right click on a project and choose Properties
      • Under Configuration Properties > C/C++ > PreProcessor, append ";_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T" at the end of the Preprocessor Definitions.(screen shot)
      • Click OK.
  • Pick ReleaseForDownload in the Solution COnfigurations drop-down box. Do the same thing (as 1 to 7 above) again.

Congratulations! You've converted solution file and project files.

NOTE: You need to do this by hand everytime a new viewer version is released...

Workarounds

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

unistd.h (Express only)

  • If you are using Visual C++ Express, create an empty file at "linden\libraries\include\unistd.h"
  • This should not be needed if you are using Visual Studio.

Disable llMozLib

LL supplied pre-compiled llMozLib requires C++ class library come with VS2003. You can't link it with VS2005 class library. Workaround is to disable it as follows:

  • linden\indra\llcommon\llpreprocessor.h @ line 51 (two lines below #elif LL_WINDOWS)
--51: #define LL_LIBXUL_ENABLED		1
++51: #define LL_LIBXUL_ENABLED		0

Ignore test project

For whatever reason, the test project doesn't work under VS2005. Workaround is to disable it as follows:

  • Right click on the test and choose Unload Project.

Using Recent Windows SDK

  • See VWR-426 if you have recent Windows SDK.

Ready, Set, Build!

  • Build either ReleaseNoOpt (for debugging) or ReleaseForDownload (for production).
  • SecondLife.exe will be built in linden\indra\newview\ReleaseNoOpt or linden\indra\newview\ReleaseForDownload
  • Create a shortcut to SecondLife.exe, and change the start location to linden\indra\newview\ (all the .dll will be found there.)

Problems Running?

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

Cannot open include file: 'windows.h' problem

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

Fix it with this: (thanks Fairlight!)

set INCLUDE=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include;%INCLUDE%
set LIB=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib;%LIB%