Difference between revisions of "Compile ECWolf on Windows"

From ECWolf Wiki
(Update compile instructions to reflect latest Mercurial)
Line 3: Line 3:
 
== Dependencies ==
 
== Dependencies ==
  
The following programs/libraries are used by ECWolf.  The versions listed below are known to work, however other versions may work.
+
The following programs are used by ECWolf.  The versions listed below are known to work, however other versions may work.
* [http://cmake.org/ CMake] 2.8.12 or later
+
* [http://cmake.org/ CMake] 3.11 or later (2.8.12 is the minimum but 3.11 or later is recommended)
 +
* [http://tortoisehg.bitbucket.io/ Mercurial]
 +
* Compiler of your choice. [https://visualstudio.microsoft.com Visual Studio 2017] is recommended, but one can also use Visual Studio 2005 or MinGW-w64 8.1.
 +
 
 +
 
 +
In addition to the above, ECWolf comes with a copy of the following which can optionally be compiled separately if you are so inclined.
 
* [http://www.libsdl.org/ libSDL] 2.0.5 (2.0.6 or later will compile, but there are some issues with the audio overhaul at this time.)
 
* [http://www.libsdl.org/ libSDL] 2.0.5 (2.0.6 or later will compile, but there are some issues with the audio overhaul at this time.)
 
* [http://maniacsvault.net/ecwolf/files/tools/dev/ SDL_mixer for ECWolf] (Standard [https://www.libsdl.org/projects/SDL_mixer/ SDL_mixer] 2.0.1 will work, but features will be disabled.)
 
* [http://maniacsvault.net/ecwolf/files/tools/dev/ SDL_mixer for ECWolf] (Standard [https://www.libsdl.org/projects/SDL_mixer/ SDL_mixer] 2.0.1 will work, but features will be disabled.)
* [https://www.libsdl.org/projects/SDL_net/ SDL_net] 2.0.1 {{hg}}
+
* [https://www.libsdl.org/projects/SDL_net/ SDL_net] 2.0.1
 
 
In addition to the above, ECWolf comes with a copy of the following which can optionally be compiled separately if you are so inclined.
 
 
* [http://www.zlib.net/ zlib] 1.2.11
 
* [http://www.zlib.net/ zlib] 1.2.11
 
* [http://bzip.org/ bzip2] 1.0.6
 
* [http://bzip.org/ bzip2] 1.0.6
 
* [http://ijg.org/ jpeg] 6b
 
* [http://ijg.org/ jpeg] 6b
  
[http://tortoisehg.bitbucket.org/ Mercurial] is also needed to checkout a copy of the latest source. You will also need a compiler. MinGW and MSVC 2005 or later should work fine. The steps are more or less the same for both.
+
 
 +
Note that it is also possible to build with vanilla MinGW for legacy OS support, but you will need to use SDL 1.2 (Set FORCE_SDL12 in CMake) and provide SDL and SDL_net yourself. You can use the internal SDL_mixer with both SDL2 and SDL 1.2.
  
 
== Retrieving the Source ==
 
== Retrieving the Source ==
 
Use Mercurial to retrieve the latest version of the source.
 
Use Mercurial to retrieve the latest version of the source.
 
  hg clone [https://bitbucket.org/ecwolf/ecwolf https://bitbucket.org/ecwolf/ecwolf]
 
  hg clone [https://bitbucket.org/ecwolf/ecwolf https://bitbucket.org/ecwolf/ecwolf]
 +
 +
Mercurial will also automatically download SDL, SDL_mixer, and SDL_net sources during this stage.
  
 
== Compiling ==
 
== Compiling ==
 
First open the CMake GUI and put the location to the source code in the source code path. (Note that this is not the src directory in the repository but the root.) Then for the directory to build the binary in, create a build directory in the source code directory and use that. Once the two paths are entered click "Configure."
 
First open the CMake GUI and put the location to the source code in the source code path. (Note that this is not the src directory in the repository but the root.) Then for the directory to build the binary in, create a build directory in the source code directory and use that. Once the two paths are entered click "Configure."
  
Here select the compiler you're going to generate the project for. Use MinGW Makefiles for MinGW or select the Visual Studio version if you are using that. Once you've made your selection, click "Finish."
+
Here select the compiler you're going to generate the project for. Select the Visual Studio version you're using or MinGW Makefiles if you're using MinGW. Once you've made your selection, click "Finish."
 +
 
 +
CMake should be able to configure the project successfully.  When it does click "Generate."
 +
 
 +
For MSVC you will now have a sln file which should build successfully. For MinGW open a command propmt and cd to the build directory and type mingw32-make.
  
At this point CMake will likely error because it can't find SDL. Find the SDL_INCLUDE_DIR and SDL_LIBRARY_TEMP and set them accordingly (SDL_LIBRARY_TEMP should point to SDL2.lib for MSVC or SDL2.dll for MinGW)Once you do that, clicking configure, and it will complain about SDL_mixer. Do basically the same thing only for SDL_MIXER variables and click "Configure" again.  For the latest development version repeat for SDL_NET. It should succeed so click "Generate."
+
=== Building with static runtime ===
 +
By default ECWolf will be configured to use dynamically linked C runtimesIf this is undesirable set the following in CMake.
  
For MSVC you will now have a sln file which should build successfully. For MinGW open a command propmt and cd to the build directory and type mingw32-make. With MSVC you can statically link the standard library by adding /MT to CMAKE_CXX_FLAGS_RELEASE. MinGW can do the same by adding -static-libgcc.
+
* '''Visual Studio'''
 +
: Change /MD to /MT and /MDd to /MTd in the CMAKE_CXX_FLAGS_* and CMAKE_C_FLAGS_* variables.
 +
* '''MinGW-w64'''
 +
: Set CMAKE_EXE_LINKER_FLAGS to:
 +
: <pre>-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive</pre>
 +
* '''MinGW'''
 +
: Set CMAKE_EXE_LINKER_FLAGS to:
 +
: <pre>-static-libgcc -static-libstdc++</pre>

Revision as of 05:58, 19 August 2018

This guide will demonstrate how to compile the Mercurial version of ECWolf on Windows.

Dependencies

The following programs are used by ECWolf. The versions listed below are known to work, however other versions may work.

  • CMake 3.11 or later (2.8.12 is the minimum but 3.11 or later is recommended)
  • Mercurial
  • Compiler of your choice. Visual Studio 2017 is recommended, but one can also use Visual Studio 2005 or MinGW-w64 8.1.


In addition to the above, ECWolf comes with a copy of the following which can optionally be compiled separately if you are so inclined.


Note that it is also possible to build with vanilla MinGW for legacy OS support, but you will need to use SDL 1.2 (Set FORCE_SDL12 in CMake) and provide SDL and SDL_net yourself. You can use the internal SDL_mixer with both SDL2 and SDL 1.2.

Retrieving the Source

Use Mercurial to retrieve the latest version of the source.

hg clone https://bitbucket.org/ecwolf/ecwolf

Mercurial will also automatically download SDL, SDL_mixer, and SDL_net sources during this stage.

Compiling

First open the CMake GUI and put the location to the source code in the source code path. (Note that this is not the src directory in the repository but the root.) Then for the directory to build the binary in, create a build directory in the source code directory and use that. Once the two paths are entered click "Configure."

Here select the compiler you're going to generate the project for. Select the Visual Studio version you're using or MinGW Makefiles if you're using MinGW. Once you've made your selection, click "Finish."

CMake should be able to configure the project successfully. When it does click "Generate."

For MSVC you will now have a sln file which should build successfully. For MinGW open a command propmt and cd to the build directory and type mingw32-make.

Building with static runtime

By default ECWolf will be configured to use dynamically linked C runtimes. If this is undesirable set the following in CMake.

  • Visual Studio
Change /MD to /MT and /MDd to /MTd in the CMAKE_CXX_FLAGS_* and CMAKE_C_FLAGS_* variables.
  • MinGW-w64
Set CMAKE_EXE_LINKER_FLAGS to:
-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive
  • MinGW
Set CMAKE_EXE_LINKER_FLAGS to:
-static-libgcc -static-libstdc++