In Memoriam: Tai'lahr

OpenUru.org, along with the rest of the Mystonline community, is mourning the loss of Tai'lahr on October 16th, 2019.

Rest in Peace, friend.

Difference between revisions of "Build the client with MSVC 2008"

From OpenUru
Jump to navigation Jump to search
m (Add the UruDocProject header and category footer tags)
m (Changed referenced PR. The previous PR was created incorrectly, and is now invalid.)
Line 7: Line 7:
 
Please note that the client created using these instructions has not undergone extensive testing.<BR>
 
Please note that the client created using these instructions has not undergone extensive testing.<BR>
  
These instructions need the project files from [https://bitbucket.org/OpenUru_org/cwe-ou/pull-requests/45 Pull request #45] on the CWE bitbucket.
+
These instructions need the project files from [https://bitbucket.org/OpenUru_org/cwe-ou/pull-requests/48 Pull request #48] on the CWE bitbucket.
  
 
== Items needed to compile ==
 
== Items needed to compile ==

Revision as of 03:27, 26 October 2019


Introduction

This document provides steps to build the CWE client with MSVC 2008 SP1 Express, with minimal changes from the current CWE-OU source as of 05-Dec-2018 [1].
This is an attempt to enhance the usability of the CWE-ou source tree by utilizing a freely available compiler and some updated libraries.

Please note that the client created using these instructions has not undergone extensive testing.

These instructions need the project files from Pull request #48 on the CWE bitbucket.

Items needed to compile

Notes

  • Libogg 1.3.2 was used because xiph removed the VS2008 projects from 1.3.3.
  • The client has physics bugs (cannot step off the Kadish elevator, and such) when compiled with PhysX 2.6.4 (the only available version). If you can obtain it, PhysX 2.6.0 is the version Cyan used, and clients compiled with it do not seem to have these physics bugs.
  • You must use a 2.6.x version of PhysX for CWE, because the cooked mesh format was changed in PhysX 2.7.x and later.
  • Some minor source changes are required in order to compile with VS 2008 SP1 Express version. Those will be documented below.
  • All libraries are compiled with "Whole Program Optimization" turned off.
  • All release version libraries are compiled as "Multi-threaded DLL (/MD)"
  • All debug version libraries are compiled as "Multi-threaded Debug DLL (/MDd)"
  • It is understood that the specified DirectX SDK (Aug 2007) has expired messages for one of it's components. The client does not use that particular component, and we are using that DirectX SDK version because it is the newest available SDK that does not require source changes to use. The earlier October 2005 version is no longer available from Microsoft.


  • Crypto keys are located in "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\NucleusLib\pnNetBase". Edit the *.hpp files with a text editor to replace Cyan's keys with your own server's keys. Always clean your solution and rebuild when you change crypto keys, to make sure they are updated.
  • Server hostnames, IP addresses, and ports are located in the following files:

The status URL:
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp"
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp"

The auth/gatekeeper address
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp"

The default client port
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/pnNbConstant.h"

Build preparation steps

  1. Obtain CWE-OU source
  2. Install Visual Studio 2008 SP1 Express
  3. Copy the include and lib directories from the SDK installed with VS2008 SP1 Express to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\PlatformSDK". The directory where the SDK resides will most likely be "Program Files\Microsoft SDKs\Windows\v6.0A". As the SDK is in our path, this step is probably not necessary but we will do it for consistency.

    Directory structure in the CWE tree will look like this:
    StaticSDKs
      Win32
        PlatformSDK
          include
          lib
  4. Install the OpenAL SDK and copy the include and lib directories to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\OpenAL 1.1 with EFX SDK"

    Directory structure in the CWE tree will look like this:
      StaticSDKs
        win32
          OpenAL 1.1 with EFX SDK
            include
            libs
    
  5. Install the DirectX 9.0c SDK (Say "OK" to the expired xaudio2 messages - we do not use that) and copy it to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\DX9.0c".

    Directory structure in the CWE tree will look like this:
      StaticSDKs
        Win32
          DX9.0c
            include
            Lib
    
  6. Copy PhysX subdirectories from "Program Files\AGEIA Technologies\AGEIA PhysX SDK\v2.6.4\SDKs" and "Program Files (x86)\AGEIA Technologies\AGEIA PhysX SDK\v2.6.4\Bin" to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\PhysX"

    Directory structure in the CWE tree will look like this:
      StaticSDKs
        Win32
          PhysX
            Bin
            Cooking
            Docs
            Foundation
            Framework
            lib
            ...

  7. Build Ogg and Vorbis
    1. Create a directory and extract Ogg and Vorbis archives to it.
      oggvorbis
        libogg-1.3.2
        libvorbis-1.3.6
    2. Change directory to "libvorbis-1.3.6\win32\vs2008" and edit the libogg.vsprops file. Change the "LIBOGG_VERSION" value to match your version of Ogg (1.3.2 in this document).
    3. Open "libogg-1.3.2\win32\VS2008\libogg_static.sln" in the Visual Studio IDE.
    4. Click on configuration drop-down on the upper left and select "Release"
    5. Right click on project in the solution explorer and select properties.
    6. Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
    7. Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded DLL (/MD)"
    8. Click on "Apply"
    9. Click on configuration drop-down on the upper left of the properties page and select "Debug"
    10. Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
    11. Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded Debug DLL (/MDd)"
    12. Click "Apply" and then "OK".
    13. On the IDE toolbar, select "Release" from the drop down. then right click on the project in the solution explorer and select "Build".
    14. On the IDE toolbar, select "Debug" from the drop down. then right click on the project in the solution explorer and select "Build".
    15. Open "libvorbis-1.3.6\win32\VS2008\vorbis_static.sln" in the Visual Studio IDE.
    16. Repeat steps "d" through "n" for libvorbis_static and libvorbisfile.
  8. Copy Ogg and Vorbis files to CWE
    1. Copy the ogg and vorbis include directories into "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\include". It is okay to let it overwrite.
    2. Copy the "libogg-1.3.2\win32\VS2008\Win32\Release" and "Debug" directories into "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\lib"
    3. Copy the "libvorbis-1.3.6\win32\VS2008\Win32\Release" and "Debug" directories to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\lib"
    4. Directory structure in the CWE tree will look like this:
        StaticSDKs
          win32
            oggvorbis
              include
                ogg
                vorbis
              lib
                Debug
                Release
  9. Build Speex 1.2.0
    1. Create a directory and extract the Speex 1.2.0 archive into it.
    2. Unfortunately, the speex-1.2.0 release is missing the "fftwrap.c" file. Obtain the missing file from the Speex github repository and copy it into "speex-1.2.0\libspeex" directory (the directory that also has "fftwrap.h" in it). fftwrap.c
    3. Open "speex-1.2.0\win32\VS2008\libspeex.sln" in the VS2008 IDE. Ignore "project missing" errors - we are only building libspeex.
    4. Click on configuration drop-down on the upper left and select "Release_RTL_dll"
    5. Right click on the "libspeex" project in the solution explorer and select properties.
    6. Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
    7. Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded DLL (/MD)"
    8. Click on "Apply"
    9. Click on configuration drop-down on the upper left of the properties page and select "Debug_RTL_dll"
    10. Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
    11. Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded Debug DLL (/MDd)"
    12. Click "Apply" and then "OK".
    13. On the IDE toolbar, select "Release_RTL_dll" from the drop down. then right click on the "libspeex" project in the solution explorer and select "Build".
    14. On the IDE toolbar, select "Debug_RTL_dll" from the drop down. then right click on project in the solution explorer and select "Build".
  10. Copy the "Speex-1.2.0" you just compiled into "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32".
      StaticSDKs
        win32
          speex-1.2.0
            doc
            include
            libspeex
            ...
  11. Compile and install OpenSSL (see Build OpenSSL with MS Visual C++). As this is security software, it is best (in my opinion) to compile it yourself from source. You can choose either static or dynamic linking.
    Note: If you link it dynamically, it will cause the Uru client to require the OpenSSL DLLs to be present in the client directory or in the system path.

    Copy the installed stuff to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\OpenSSL" (created by "make install" - you do not want your development tree here).

    Directory structure in the CWE tree will look like this:
      StaticSDKs
         Win32
           OpenSSL
             bin
             include
               openssl
             lib
  12. Open "Visual Studio 2008 Command Prompt" and change to the "CWE\MOULOpenSourceClientPlugin\StaticSDKs\XPlatform\jpeg-8c-rgba directory." Copy makefile.vc to makefile.nmake, and jconfig.vc to jconfig.h and then run nmake nodebug=1 -f makefile.nmake. This will build the library in non-debug mode. If you use a debug library, the linker will complain when we link the client executable.
  13. Install zlib and libpng
    1. Download zlib127.zip (or a newer version) from http://www.zlib.net/, extract the zlib-1.2.7 folder it contains and move/rename it to MOULOpenSourceClientPlugin/StaticSDKs/XPlatform/zlib.
    2. Download lpng1511.zip (or a newer version) from http://libpng.org/pub/png/libpng.html, extract the lpng1511 folder it contains and move/rename it to MOULOpenSourceClientPlugin/StaticSDKs/XPlatform/png.
    3. Open png/projects/visualc71/libpng.sln in the Visual Studio 2008 IDE.
    4. Right-click on the “libpng” project in the Solution Explorer and choose Properties.
    5. Select configuration “LIB Debug” in the popup menu at the top.
    6. Select Configuration Properties > C/C++ > Code Generation on the left.
    7. Change the Runtime Library line to “Multi-threaded Debug DLL (/MDd)”. (This step avoids a warning in the final Plasma build. As far as I understand, leaving it out is harmless, but better do it to be sure.)
    8. Choose the “LIB Release” configuration and set Runtime Library to “Multi-threaded DLL (/MD)”.
    9. Repeat steps 4 to 8 for the other two projects “pngtest” and “zlib”.
    10. Select “LIB Debug” from the Solution Configurations popup menu in the toolbar, then Build > Build Solution.
    11. Select the “LIB Release” configuration and build the solution.
    12. Make a new folder png/lib and move png/projects/visualc71/Win32_LIB_Debug/libpngd.lib as well as png/projects/visualc71/Win32_LIB_Release/libpng.lib into it.
    13. Make a new folder zlib/lib and move png/projects/visualc71/Win32_LIB_Debug/ZLib/zlibd.lib as well as png/projects/visualc71/Win32_LIB_Release/ZLib/zlib.lib into it.

Required source code changes

  1. plFileUtils.cpp file located in directory "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\PubUtilLib\plFile"
    Remove the "#include <errno.h>" line from the "#if HS_BUILD_FOR_UNIX" section and move it under "#include <sys/stat.h>"
    Before
    #include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    
    
    #if HS_BUILD_FOR_WIN32
    #include <direct.h>
    #include <io.h>
    #endif
    
    #if HS_BUILD_FOR_UNIX
    #include <unistd.h>
    #include <errno.h>
    #include <utime.h>
    #endif
    

    After

    #include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <errno.h>
    
    #if HS_BUILD_FOR_WIN32
    #include <direct.h>
    #include <io.h>
    #endif
    
    #if HS_BUILD_FOR_UNIX
    #include <unistd.h>
    #include <utime.h>
    #endif
    
  2. hsWindows.h file located in directory "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\CoreLib"
    Change the _MSC_VER >=1600 to 1500.
    Before
    #ifndef __AFX_H__   // MFC apps won't let us include windows from here. =(
    
    #if defined(_MSC_VER) && _MSC_VER >= 1600
    #define _WIN32_WINNT 0x0501
    #else
    #define _WIN32_WINNT 0x0400
    #endif
    

    After

    #ifndef __AFX_H__   // MFC apps won't let us include windows from here. =(
    
    #if defined(_MSC_VER) && _MSC_VER >= 1500
    #define _WIN32_WINNT 0x0501
    #else
    #define _WIN32_WINNT 0x0400
    #endif
    
  3. plClient.rc file located in "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\Apps\plClient\res\"
    We do not have MFC with VS2008 SP1 Express, so we need to replace the first reference to afxres.h. The client portion of CWE does not use MFC (I believe the MAX plugin does), so we can make this replacement.
    Before
    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "afxres.h"
    

    After

    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    //#include "afxres.h"
    
    #include <windows.h>
    #define IDC_STATIC (-1)
    
  4. plUruLauncher.rc file located in "CWE\MOULOpenSourceClientPlugin\Plasma20\Apps\plUruLauncher.rc"
    This is the same change we just made in the previous file.
    Before
    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "afxres.h"
    

    After

    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    //#include "afxres.h"
    
    #include <windows.h>
    #define IDC_STATIC (-1)
    


Build the client

Now that the prep is done, you can actually build the client.

  1. Open the "CWE\MOULOpenSourceClientPlugin\Plasma20\MSVC8Projects\Plasma\Apps\AllClient\AllClient-ou.sln" in the VS2008 IDE.
  2. Select the type of build you want from the dropdown on the IDE toolbar.
    • Release
    • Release_Internal
    • Debug
    • Debug_Internal
  3. Right click on the "AllClient" project and select "Build".

  4. Completed builds are copied into the "CWE\MOULOpenSourceClientPlugin\Plasma20\test" directory.
    Note: You *must* make sure your client is using the same versions of the PhysX DLLs that you built with. They are not compatible from version to version.

If, after building the client, you require the server prep tools (plFileSecure, plFileEncrypt, plPythonPak), right click on those specific projects and click "Build".
The compiled files will be copied into the "CWE\MOULOpenSourceClientPlugin\Plasma20\tools" directory.

DirectX notes

It is possible to use the latest DirectX 9.0c SDK (June 2010) with some more source changes. The client compiles and runs with these changes, but it has not been extensively tested. This basic documentation is here in case Microsoft decides to pull the link for the DX Aug 2007 SDK.

  • In file "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\PubUtilLib\plPipeline\plDXPipeline.cpp":
    Change "#include <dxerr9.h>" to "#include <dxerr.h>"
    Change "DXGetErrorString9" to "DXGetErrorString"

  • In file "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\PubUtilLib\plAudio\plWavFile.cpp":
    Change "#include <dxerr9.h>" to "#include <dxerr.h>"

  • In file "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\PubUtilLib\plAudio\plEAXEffects.cpp":
    Remove the "#include <dmusici.h>" line
    Change "#include <dxerr9.h>" to "#include <dxerr.h>"

  • In the "plPageOptimizer" project:
    Remove all linker references to "dplayx.lib"
    Change all linker references of "dxerr9.lib" to "dxerr.lib"

  • In the "plClient" project:
    Remove all linker references to "dplayx.lib"
    Change all linker references of "dxerr9.lib" to "dxerr.lib"

  • In the "plUruLauncher" project:
    Change all linker references of "dxerr9.lib" to "dxerr.lib"