Version 15 (modified by Stan, 4 years ago) ( diff )

Add treat warning as error removal in projects else Fcollada won't build.

This page will document how to build the game's Windows dependencies, useful for updating them to newer versions.

This is a work in progress and incomplete. It can also include libraries that are not (yet) dependencies.

boost

Note: bcp will be used to generate a subset of Boost libs from the game's source code.

Note: This works as well with VS 2015 and 2017, just start the correct Tools Command Prompt and replace the toolset version by 14.0_xp or 14.1_xp.

  • Command line MSVC build:
    • Download Boost Windows source archive and extract somewhere (X:\path\to\boost_x_xx_x)
    • Run VS2013 x86 Native Tools Command Prompt from the start menu (under Visual Studio 2013 > Visual Studio Tools)
    • Change directory to Boost source location
      cd X:\path\to\boost_x_xx_x
      md minimal
      
    • Run bootstrapper to build Boost.Build
      bootstrap.bat
      
    • Build bcp tool
      b2.exe tools/bcp
      
    • Run bcp on game's source code (from X:\path\to\source) to generate subset of Boost libs in minimal\:
      SET 0ad_source=X:\path\to\source
      FOR /f "tokens=*" %i IN ('dir /s /b %0ad_source%\*.cpp %0ad_source%\*.h %0ad_source%\*.hpp') DO dist\bin\bcp.exe --scan --boost=X:\path\to\boost_x_xx_x %i minimal >> bcp.log 2>&1
      
    • Copy these files to minimal\ (bcp can be used to do this, if desired):
      • b2.exe
      • bjam.exe
      • boostcpp.jam
      • boost-build.jam
      • project-config.jam
      }}}
    • Copy tools to minimal\tools
    • Copy libs\config to minimal\libs\config
    • Build filesystem and system libs into minimal\stage directory with the XP support toolset
      cd minimal
      b2.exe --with-filesystem --with-system --toolset=msvc-12.0_xp variant=debug,release link=static runtime-link=shared threading=multi stage
      
    • stage\lib contains debug and release multithreaded static libs to copy into libraries\win32\boost\lib:
      • libboost_system-vc120-mt-x_xx.lib
      • libboost_system-vc120-mt-gd-x_xx.lib
      • libboost_filesystem-vc120-mt-x_xx.lib
      • libboost_filesystem-vc120-mt-gd-x_xx.lib
    • minimal\boost contains headers to copy into libraries\win32\boost\include

enet

  • Download the latest source code from http://enet.bespin.org/Downloads.html.
  • Follow the instructions at http://enet.bespin.org/Installation.html:
    • Open enet.dsp and upgrade the project.
    • In the project properties:
      • For all configurations, add ws2_32.lib and winmm.lib to the list of linked libraries.
      • For the Debug configuration, add the d suffix to the Target name so it becomes $(ProjectName)d.
    • Build the Debug and Release versions.
    • In the project properties, for all configurations, change the target type to a DLL. Add ENET_DLL to the list of preprocessor definitions.
    • Build the Debug and Release versions once more.
  • Copy Debug/enetd.lib and Release/enet.lib to libraries/win32/enet/lib/
  • Copy Debug/enetd.dll and Release/enet.dll to binaries/system/
  • Copy include/enet to libraries/win32/enet/include/

FCollada

  • Open libraries/source/fcollada/src/FCollada/FCollada.sln in VS. Let it upgrade the project.
  • Switch to v120_xp toolset for compatibility with WinXP:
    • Open the properties for the FCollada project
    • Change the Configuration to All Configurations
    • Change Platform Toolset to Visual Studio 2013 - Windows XP (v120_xp)
    • Disable the treat warning as error flag.
  • Build Debug DLL Win32 and Release DLL Win32. Ignore the Unicode and Retail configurations.
  • In both configurations, FColladaTest will fail to link. This is not an issue. You can delete the FColladaTest project if you want to feel better about the build output.
  • Next to FCollada.sln, there is now an Output directory.
    • Copy Output/FColladaD.lib and Output/FCollada.lib to libraries/source/fcollada/lib/.
    • Copy Output/Debug DLL Win32/FColladaD.dll and Output/Release DLL Win32/FCollada.dll.
    • If you need the debug symbols, they are in Output/Debug DLL Win32/FCollada/FCollada.pdb.

Alternatively you can use this script after updating the sln with visual studio.

gloox

  • Download the latest 1.0.x source code from https://camaya.net/gloox/download/.
  • Decompress and open gloox.vcproj in VS. Let it upgrade the project.
  • Fix the Debug configuration:
    • Right-click the gloox-1.0 project and click Properties
    • Copy-paste the Output directory value from the Release project (it should be $(SolutionDir)$(Configuration)\ instead of some hardcoded thing)
    • Add the d suffix to the Target name so it becomes $(ProjectName)d
  • Fix the compilation failure by adding iodata.h and iodata.cpp to the project (see http://stackoverflow.com/questions/28319149/)
  • Build the Release and Debug configurations
  • Copy Debug/gloox-1.0d.lib and Release/gloox-1.0.lib to libraries/win32/gloox/lib/
  • Copy Debug/gloox-1.0d.dll and Release/gloox-1.0.dll to binaries/system/
  • Copy all the header files from src to libraries/win32/gloox/include/gloox

Now we need to rebuild the glooxwrapper project. Just run update-workspaces.bat with the argument --build-shared-glooxwrapper and build the Release and Debug configurations of the game.

libcurl

Note: the included CMake scripts are outdated, but there are also untested makefiles for a command line build

  • Bundled MSVC project:
    • Download libcurl source and extract somewhere
    • Open projects\Windows\VC12\curl-all.sln
    • Switch to v120_xp toolset for compatibility with WinXP:
      • Open the properties for the libcurl project
      • Change the Configuration to All Configurations
      • Change Platform Toolset to Visual Studio 2013 - Windows XP (v120_xp)
    • Build both DLL Debug - DLL Windows SSPI and DLL Release - DLL Windows SSPI configurations (in order to enable native SSL support).
    • Binaries are located in build\Win32\VC12\DLL Debug\ and build\Win32\VC12\DLL Release\
      • Copy the *.dll files to binaries\system, *.lib files to libraries\win32\libcurl\lib
    • Copy the *.h files from include\curl to libraries\win32\libcurl\include\curl

libiconv

Note: iconv doesn't support MSVC anymore, only mingw and cygwin

  • Create Visual Studio project:

http://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio

libicu

Note: Visual Studio projects are included for VS2010, building with a newer version requires the following procedure

  • Cygwin-based MSVC build:
    • Install Cygwin with bash, GNU make, ar, ranlib, man
    • Download libicu .zip source and extract somewhere
    • Open Windows command prompt
    • Create build and install directories for organization:
      cd icu
      md install
      cd source
      md build
      cd build
      
    • Set MSVC build environment by running
      "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
      
    • Add Cygwin bin directory to path (e.g. X:\cygwin64\bin)
      SET path=%path%;X:\cygwin64\bin
      
    • Set recommended ICU build flags (see build documentation)
      SET CPPFLAGS=-DU_USING_ICU_NAMESPACE=0 -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1
      
    • Configure XP-compatible platform toolset (based on Windows XP Targeting with C++ in Visual Studio 2012)
      SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
      SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
      SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
      SET CL=/D_USING_V110_SDK71_
      SET LINK=/SUBSYSTEM:WINDOWS,5.01
      
    • Build and install to X:/path/to/install (note forward slashes -- this runs in Bash!)
      bash ../runConfigureICU Cygwin/MSVC --prefix=X:/path/to/install
      make
      make check
      make install
      
    • X:\path\to\install\lib will contain the .dlls and .libs
    • X:\path\to\install\include will contain the header files

libpng

Note: Depends on zlib, so if you're building it too, do that first. Note down the install path where CMake installed the zlib build output.

  • CMake GUI-based build:
    • Download libpng source .zip and extract somewhere (X:\path\to\lpng1xxx)
    • Open cmake-gui (v3.8 in this example)
    • Set source location to the X:\path\to\lpng1xxx
    • Set build location to X:\path\to\lpng1xxx\build (so the build files will be separate from the source)
    • Press Configure
      • Choose Yes to create the build directory if it doesn't exist
    • Choose Visual Studio 12 2013 default native compiler as generator. Set the value of Optional toolset to use to v120_xp (to use the XP compatible toolset), then Finish
    • There should be an error because it can't find zlib yet
    • Set ZLIB_ROOT to the install path of the zlib build output
    • Change CMAKE_INSTALL_PREFIX to X:\path\to\lpng1xxx\installdir (install is not possible because of the existing INSTALL file)
    • Press Configure until there are no errors or red entries
    • Press Generate
    • Press Open project
    • Open png project properties, select Debug configuration. Under Configuration Properties > Linker > Input > Additional Dependencies, add a "d" onto the end of the zlib1 .lib filename (so it uses the zlib debug build in this case)
    • Optional DLL version info: Right-click on the png project, click Add > Existing element and select lpng1xxx\scripts\pngwin.rc
    • Build solution for Debug configuration, there should be no errors. Build the INSTALL project to copy files to the install folders set up earlier
    • Repeat for Release configuration
    • lpng1xxx\installdir should contain the newly built libs

libsodium

Download the latest source from https://download.libsodium.org/libsodium/releases/.

It contains a folder builds/msvc/ with all the solutions for recent and old versions of Visual Studio. Pick yours.

Open Project > Properties.

  • Select All configurations and change the toolset to support target XP.
  • Select all Debug configurations (either one by one or with the multiple selection tool) and change Target Name so that d is added to the filename base (for instance $(TargetName)d instead of $(TargetName)).
  • Build both Dynamic configurations.
  • Copy bin/Win32/{Debug,Release}/[toolset]/dynamic/libsodium{d,}.dll to binaries/system/.
  • Copy bin/Win32/{Debug,Release}/[toolset]/dynamic/libsodium{d,}.lib to libraries/win32/libsodium/lib/.
  • Copy headers to libraries/win32/libsodium/include/. It looks like the build doesn't create a minimal folder of headers, so my advice is downloading the zip with prebuilt libs for msvc from the download page and using the include folder from that.

libxml2

Note: Depends on iconv, so if you're building it too, do that first.

  • Command line MSVC build:
    • Download libxml2 source tarball and extract somewhere (X:\path\to\libxml2-x.x.x)
    • Open Windows command prompt in the libxml2-x.x.x\win32 subdirectory
    • Run configure script to install in X:\path\to\install and pull in iconv lib from X:\path\to\iconv (for SVN, this is libraries\win32\iconv)
      cscript configure.js compiler=msvc prefix=X:\path\to\install include=X:\path\to\iconv\include lib=X:\path\to\iconv\lib
      
      Note: spaces are NOT allowed in these paths!
    • There should be no errors if it completed successfully
    • Set MSVC build environment
      "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
      
    • Configure XP-compatible platform toolset (based on Windows XP Targeting with C++ in Visual Studio 2012)
      SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
      SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
      SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
      SET CL=/D_USING_V110_SDK71_
      SET LINK=/SUBSYSTEM:WINDOWS,5.01
      
    • Modify Makefile.msvc to search for correct libiconv lib:
      !if "$(WITH_ICONV)" == "1"
      LIBS = $(LIBS) libiconv.lib
      !endif
      
    • Build and install
      nmake /f Makefile.msvc
      nmake /f Makefile.msvc install
      

NVTT

Note: We build the custom version included in SVN. Depends on libpng and zlib, so if you're building those too, do that first.

  • CMake GUI-based build:
    • Download and install Microsoft DirectX SDK (June 2010)
    • Open X:\path\to\0ad\libraries\source\nvtt\src\CMakeLists.txt in a text editor, remove or comment out all blocks referencing WIN32/gnuwin32, and save.
    • Open cmake-gui (v3.14 in this example)
    • Set source location to X:\path\to\0ad\libraries\source\nvtt\src
    • Set build location to X:\path\to\0ad\libraries\source\nvtt\src\build
    • Press Configure
      • Choose Yes to create the build directory if it doesn't exist
    • Choose Visual Studio 14 2015 default native compiler as generator. Set the value of Optional toolset to use to v140_xp (to use the XP compatible toolset), then Finish
    • Under Ungrouped Entries, uncheck/turn off CG, CUDA, GLEW, GLUT, JPEG, OPENEXR, TIFF
    • Under ZLIB, set ZLIB_INCLUDE_DIR to X:\path\to\0ad\libraries\win32\zlib\include, ZLIB_LIBRARY_DEBUG/RELEASE to X:\path\to\0ad\libraries\win32\zlib\lib\zlib1.lib/zlib1d.lib
    • Under PNG, set PNG_PNG_INCLUDE_DIR to X:\path\to\0ad\libraries\win32\libpng\include, PNG_LIBRARY_DEBUG/RELEASE to X:\path\to\0ad\libraries\win32\libpng\lib\libpng16.lib/libpng16d.lib
    • Change CMAKE_INSTALL_PREFIX to X:\path\to\0ad\libraries\source\nvtt\src\install
    • Add Entry for NVTT_SHARED of Type BOOL and Value checked/turned on
    • Press Configure until there are no errors or red entries (warnings are OK)
    • Press Generate
    • Press Open project
    • TODO: patches for VS 2015 build errors (or update NVTT version, #4549)
    • TODO: configure only nvtt as dynamic (.dll), configure nvcore, nvimage and nvmath as static (.lib)
    • Build solution for RelWithDebInfo configuration (to generate PDBs)
      • Build the INSTALL project by right-clicking on it (to copy files to the install folders set up earlier)
    • X:\path\to\0ad\libraries\source\nvtt\src\install should contain all the newly built libs

OpenAL Soft

  • CMake GUI-based build:
    • Download and install Microsoft DirectX SDK (June 2010)
    • Download OpenAL-Soft source and extract somewhere (X:\path\to\openal-soft-x.xx.x)
    • Open cmake-gui (v3.2 in this example)
    • Set source location to the X:\path\to\openal-soft-x.xx.x folder
    • Set build location to X:\path\to\openal-soft-x.xx.x\build (this way the build files will be separate from the source)
    • Press Configure
      • Choose Yes to create the build directory if it doesn't exist
    • Choose Visual Studio 12 2013 default native compiler as generator, then Finish
    • Add Entry, CMAKE_GENERATOR_TOOLSET as a String, and set the value to v120_xp (to use the XP compatible toolset)
    • Change CMAKE_INSTALL_PREFIX to X:\path\to\openal-soft-x.xx.x\install
    • Uncheck/turn off ALSOFT_UTILS
    • Press Configure until there are no errors or red entries (warnings are OK)
    • Press Generate
    • In X:\path\to\openal-soft-x.xx.x\build, there should be an OpenAL.sln solution you can open in Visual Studio 2013. Open it
    • Build solution for Release configuration
      • Build the INSTALL project by right-clicking on it (to copy files to the install folders set up earlier)
    • openal-soft-x.xx.x\install should contain all the newly built libs

SpiderMonkey

  • Setting up the build environment:
    • Get the Windows Prerequisites
    • Get NSPR from here. We are using nspr-4.12 which was the newest version when SM45.0.2 was out. (Newer versions should probably work too)
      • Run mozillabuild (start-shell-msvc2015.bat) as administrator
      • Extract nspr to libraries/source/spidermonkey
        tar -xzvf nspr-4.12.tar.gz
        cd nspr-4.12
        cd nspr
        
      • Patch nspr with https://bugzilla.mozilla.org/show_bug.cgi?id=1238154#c7
      • Call configure. I've used this command:
        ./configure --disable-debug --enable-optimize --enable-win32-target=WIN95       
        
      • Call make
    • Building SpiderMonkey:
      • Adjust the absolute paths to nspr in the build.sh file to match your environment.
      • Run mozillabuild (start-shell-msvc2015.bat) as administrator and run ./build.sh.

vorbis

  • Download the latest source code for libogg and libvorbis from https://xiph.org/downloads.
  • Create a folder in which you extract libogg-1.x.x and libvorbis-1.x.x.
  • First compile libogg DLLs:
    • Open win32/VS2015/libogg_dynamic.sln. Accept to upgrade the solution.
    • In the project properties, for all configurations, change the toolset to v140_xp.
    • In the project properties, for the Debug configuration, change TargetName so that it ends with d (typically $(ProjectName)d instead of $(ProjectName).
    • Compile both configurations.
    • Copy win32/VS2015/Win32/{Debug,Release}/libogg{d,}.dll to binaries/system/.
    • Copy win32/VS2015/Win32/{Debug,Release}/libogg{d,}.lib to libraries/win32/vorbis/lib/.
  • Then compile libogg_static:
    • Open win32/VS2015/libogg_static.sln. Accept to upgrade the solution.
    • In the project properties, for all configurations, change the toolset to v140_xp.
    • Compile both configurations and don't copy anything, we don't distribute those.
  • Finally compile vorbis:
    • In win32/VS2010/libogg.props, check that LIBOGG_VERSION is the same as the one you compiled, and check that paths seem to match. Else, fix them.
    • Open libvorbis_dynamic.sln, accept to upgrade the solution.
    • For both the libvorbis and libvorbisfile projects:
      • for all configurations, change the toolset to v140_xp.
      • for the Debug configuration, change TargetName so that it ends with d.
      • for all configurations, reset Linker > General > OutputFile and Linker > Advanced > ImportLibrary to their default values (which should contain $(TargetName)).
    • For libvorbisfile (and vorbisdec and vorbisenc if you care), for the Debug configuration, in Linker > Input > Additional Dependencies, change libvorbis.lib to libvorbisd.lib.
    • Compile both configurations.
    • Copy win32/VS2010/Win32/{Debug,Release}/libvorbis{,file}{d,}.dll to binaries/system/.
    • Copy win32/VS2010/Win32/{Debug,Release}/libvorbis{,file}{d,}.lib to libraries/win32/vorbis/lib/.
  • Copy include files for ogg and vorbis.

zlib

  • CMake GUI-based build:
    • Download zlib source .zip and extract somewhere (X:\path\to\zlib-x.x.x)
    • We will start by fixing the target name for the built library. In X:\path\to\zlib-x.x.x\CMakeLists.txt, find the line that adds the 1 to the DLL name.
      Replace:
      set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
      by:
      set_target_properties(zlib PROPERTIES OUTPUT_NAME "zlib1")
      
      That way, the debug DLL will be called zlib1d.dll and not zlibd1.dll. See https://github.com/madler/zlib/issues/273.
    • Open cmake-gui (v3.8 in this example)
    • Set source location to the X:\path\to\zlib-x.x.x folder
    • Set build location to X:\path\to\zlib-x.x.x\build (this way the build files will be separate from the source)
    • Press Configure
      • Choose Yes to create the build directory if it doesn't exist
    • Choose Visual Studio 12 2013 default native compiler as generator. Set the value of Optional toolset to use to v120_xp (to use the XP compatible toolset), then Finish
    • Change CMAKE_INSTALL_PREFIX to X:\path\to\zlib-x.x.x\install
    • Delete all the INSTALL_* group entries and press Configure again. They should now all follow the path you specified during the previous step
    • Add a new BUILD_SHARED_LIBS entry and set its value to TRUE
    • Press Configure until there are no errors or red entries
    • Press Generate
    • Press Open project
    • Build solution for Debug configuration, there should be no errors
      • Build the INSTALL project by right-clicking on it (to copy files to the install folders set up earlier)
    • Repeat for Release configuration
    • zlib-x.x.x\install should contain all the newly built libs

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.