Building EDuke32 on Windows: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Line 6: Line 6:


==Building on Windows with MinGW/GCC/GNU Make==
==Building on Windows with MinGW/GCC/GNU Make==
This setup is personally used by [[Hendricks266]].


===setup===
===setup===

Revision as of 07:26, 24 June 2014

EDuke32 Distribution

Download · Source Code · APT repository · Packages
Building from source on: Linux · Windows · macOS


Getting source files

See Acquiring the EDuke32 Source Code.

Building on Windows with MinGW/GCC/GNU Make

This setup is personally used by Hendricks266.

setup

MinGW (MinGW32)

MinGW-GCC is the de facto standard for free compilers on Windows.

There are three components to setting up MinGW to build EDuke32:

  1. First, install MinGW and MSYS using the automated MinGW installer. Make sure all components are installed. This should be relatively straightforward and will install MSYS (the shell and utility commands) and MinGW (the compiler suite).
    • This guide assumes that they're installed in c:/MinGW and c:/MinGW/msys -- from the wording on their page, anything else is BAD.
  2. Next, download NASM and extract its contents to the MinGW/bin folder, so nasm.exe is located there.
    • Sample path: C:\MinGW\bin\nasm.exe
  3. After that, download, extract, and run the MinGW EDuke32 Setup Helper. (You may need to run it as an administrator for it to take full effect.) It will help ensure that everything is installed correctly as well as modify your PATH environment variable for you so you can run the compiler from any directory allowing you to compile EDuke32.

clang

Clang is another compiler that complements and works closely in tandem with MinGW. It is mainly used for its highly human readable diagnostic descriptions of compiler errors and warnings.

Installation is simple. Download the binaries marked for "Mingw32/x86", which may be marked "Experimental". From here you have two options. You can extract the contents of the archive in such a way so that its directory structure merges with MinGW's--you will have C:\MinGW\bin\clang.exe and so on. The other is to extract the data to its own folder, possibly simplifying the name, and adding it on its own to PATH--C:\clang\bin\clang.exe.

To build with clang, append the setting CLANG=1 to your make invocation.

MinGW-w64

NOTE: Unless you have a specific reason for wanting to use MinGW-w64 (such as building with native 64-bit architecture), use mainline MinGW instead.

First, you are going to want to fully install mainline MinGW using the instructions above, particularly because we need MSYS for the *nix utils it includes.

Unlike MinGW, MinGW-w64 has no organized setup procedure. Instead, the various packages contain the entire toolchain. The automated mainline builds tend to be outdated and sometimes deficient in files, so it is recommended to use rubenvb's personal builds:

The archives come in the format:

{target arch}-w64-mingw32-{compiler}-{compiler version}-{host arch}_{build creator}

Builds that produce 64-bit executables have the {target arch} "x86_64" while builds for 32-bit have "i686" (though there has been a typo, "i686_64", supposed to be "i686").

{compiler} is generally gcc, but clang is also available, and both may be installed. Where available, it is recommended to get "gcc-dw2" instead of "gcc". (The superiority of dw2 over sjlj is explained here.)

{host arch} should match the architecture of your computer. This value is completely separate from the {target arch}. If you have a 64-bit processor and OS, select a win64 package if available. If one is not available or either your processor or OS are 32-bit, grab the one marked win32. (If a win32 package is not available, you are out of luck.) Packages marked cygwin should generally be avoided. linux and mac are for cross-compiling.

You are going to want to extract these in an organized fashion. For example, you could have compilers, for your host architecture, targeting both 32-bit and 64-bit, using this directory layout:

C:\MinGW-w64\mingw32-dw2\bin\gcc.exe
C:\MinGW-w64\mingw64\bin\gcc.exe

To use MinGW-w64, the packages' bin folders needed to be added to PATH just for your current command prompt session. (It is not recommended to add MinGW-w64 to PATH by default.) Each packages contains a command script that will accomplish this for you, named mingw32env.cmd, mingw64env.cmd, clang32env.cmd, etc.

Unfortunately, one flaw in MinGW-w64 is that the two different targets have two separate executables, instead of both being in one using the -arch parameter like on *nix. When building EDuke32, the executables generated will match the target of whatever compiler is the highest in PATH--no extra make parameters needed.

One final note: If you are trying to build ebacktrace1.dll and are getting errors about a missing "bfd.h", you need to copy the following files from <root>\include\ to <root>\<target>-w64-mingw32\include\:

ansidecl.h
bfd.h
bfdlink.h
dis-asm.h
symcat.h

compiling

Now that we've got everything together, navigate a command prompt window to the base directory containing the EDuke32 source code, type

make

and cross your fingers: this will attempt to build EDuke32 and Mapster32. If you ran the MinGW EDuke32 Setup Helper earlier in the instructions, it should work.

To compile only either the game or the editor, simply give make the name of the executable, like

make eduke32.exe

To compile a version suitable for later debugging with GDB, append RELEASE=0 to the command, like this:

make RELEASE=0

To have more useful function names when doing a backtrace (see debugging below), it is also advisable to disable stack protectors, like this:

make F_STACK_PROTECTOR_ALL=-fno-stack-protector RELEASE=0

troubleshooting

If something doesn't go as planned, don't despair. Most issues are resolved rather quickly.

  • If you see a barrage of error messages saying that some symbols are not defined, check whether you have all necessary prerequisites like the DirectX SDK installed and that the paths in the Makefile point to the right location.
  • If you get errors at the end of the build process (technically, at link time), there's usually a problem with the libraries -- the linker can't find one or more .a files [needs explanation].
  • Finally, if the executable starts but aborts shortly thereafter, a dynamic link library may be missing. Usually you'll get a helpful message with its name: check the MinGW download page then.

debugging

See Troubleshooting EDuke32.

Building on Windows with Microsoft command line compilers

EDuke32 can be built using freely downloadable Microsoft tools. Unfortunately, Microsoft does not appear to offer a single package containing all the needed tools so it is necessary to get them from several different places.

  1. Download and install the Windows SDK from http://www.microsoft.com/download/en/confirmation.aspx?id=11310 and accept the defaults in the installer.
  2. Download and install the WDK from http://www.microsoft.com/download/en/details.aspx?id=11800 and select the "full development environment" option in the installer.
  3. Download and install Visual C++ 2008 Express from http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express
    • Note that the following instructions assume the above programs were installed in the default locations on a 32-bit Windows system. If they are installed in other locations then paths in later instructions will need to be adjusted.
  4. Copy lib.exe from C:\Program Files\Microsoft Visual Studio 9.0\VC\bin to C:\WinDDK\7600.16385.1\bin\x86
  5. Copy mt.exe from C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin to C:\WinDDK\7600.16385.1\bin\x86
  6. Start the "Windows XP x86 Free Build Environment" from the WDK
  7. Set up paths, etc:
set Include=C:\WinDDK\7600.16385.1\inc\api;C:\WINDDK\7600.16385.1\inc\crt

set Lib=C:\WinDDK\7600.16385.1\lib;C:\WINDDK\7600.16385.1\lib\wxp\i386;C:\WINDDK\7600.16385.1\lib\wlh\i386;C:\oggvorbis-win32sdk-1.0.1\lib;C:\WINDDK\7600.16385.1\lib\Crt\i386

PATH=C:\WinDDK\7600.16385.1\tools\sdv\bin;C:\WinDDK\7600.16385.1\bin\x86\oacr;C:\WinDDK\7600.16385.1\tools\pfd\bin\bin\x86;C:\WinDDK\7600.16385.1\tools\tracing\i386;C:\WinDDK\7600.16385.1\bin\x86;C:\WinDDK\7600.16385.1\bin\x86\x86;C:\WinDDK\7600.16385.1\bin\SelfSign;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem

Finally, change to the directory containing your EDuke32 source tree and run:

nmake -f Makefile.msvc

Building on Windows with Microsoft Visual Studio 2010

Preparation

First, follow the procedure above to download the source code. Alternatively:

AnkhSVN

First, you need to download a free SVN plugin for Visual Studio, such as:

Install AnkhSVN, you can find help for installing it from it's website.

  1. Launch Microsoft Visual Studio.
  2. Navigate through the menus: File → Subversion → Open from Subversion...
  3. Type in the URL of the EDuke32 SVN.
  4. Select the eduke32.vcxproj file and click Open.

AnkhSVN now asks you where to save the project locally.

IMPORTANT! The EDuke32 source should be located in a directory with no spaces in its name (for example C:\EDuke32\ or D:\Source\EDuke32).

Choose the local directory, the Type drop-down menu should be set to Latest Version, click on OK to save the project on your hard drive. The program now downloads the latest files from SVN.

When done, EDuke32 is shown as your current solution, now you can continue onto either fiddling with the source or just compiling it.

Compiling

Either click on the green play button, or navigate the menus to Build → Build eduke32 and VS2010 starts compiling the executables.

You will probably see a lot of warnings with wrong datatype conversions but these don't affect the outcome.