Compiling the viewer (MSVS2005)

From Second Life Wiki
Jump to navigation Jump to search

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 will also find some POSIX names deprecated and replaced by ISO C++ standards. Be sure to refer to the other compilation steps with the 2003 version for more help.

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!

Prerequisites

  • Visual Studio 2005 -or- Visual C++ 2005 Express(Free)
    • Microsoft Platform SDK
    • A DirectX 9.0 SDK released on or after Summer of 2003 DirectX 9.0 SDK (December 2006) 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.
    • 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.
  • 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.

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:

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"

gl

Quicktime

  • Download & install the 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++

Update boost from vc71 to vc80:

  • Download & install Boost++ (Pick "Visual C++ 8.0" & "Multithread, static runtime")
  • Open the Visual Studio 2005 Command Prompt
  • Delete "linden\libraries\include\boost"
  • Copy "%programfiles%\boost\boost_1_33_1\boost" to "linden\libraries\include"
  • Copy "%programfiles%\boost\boost_1_33_1\lib\libboost_regex-vc80-mt-s-1_33_1.lib"
  1. to "\linden\libraries\i686-win32\lib_release" and
  2. to "\linden\libraries\i686-win32\lib_debug"
  • Right click on the newview project, and select Properties
  • (screen shot) Under Configuration Properties, Linker, Input
    • find and change "libboost_regex-vc71-mt-s.lib"(screen shot) to "libboost_regex-vc80-mt-s-1_33_1.lib"(screen shot) in the Additional Dependencies
  • Do the same thing for the test project

unistd.h (Express only)

  • Create an empty file "linden\libraries\include\unistd.h"
  • Done!

First Steps

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:
  1. (screen shot) Under Configuration Properties, C/C++, General, change Treat Warnings As Errors to "No"
  2. (screen shot) Under Configuration Properties, C/C++, PreProcessor, insert the line ";_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T"
  3. (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 stdext::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 stdext::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 2515
--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

  • 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		0

Version: slviewer-src-20070117a

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 stdext::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\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).
  • 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?

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%