How to Compile Rebirth on Windows
#1
Updated: 04/05/18
Reason: Updated physfs version

So after lots of trial and error I've once again got a compile environment working on Windows for Rebirth.

Note: You will download several .tar.gz files. You can extract these using 7-zip.

1. Install Mingw-W64 to C:\mingw. (Click on the "Sourceforge" link). Select the following options:
Code:
Version: 6.4.0 (gcc 7 has a bug that results in a segfault when compiling Rebirth for Windows. I have reported it upstream.)
Architecture: i686
Threads: posix
Exception: dwarf
Build Revision: 0 (Or whatever is the largest number available)

2. Install Git for Windows to C:\mingw\Git (Click the "Download" link). When installing use the following settings:
Code:
Leave all the defaults on the component selection page
Use Notepad++ as Git's default editor
Use Git from the Windows Command Prompt
Use the OpenSSL Library
Checkout Windows-style, commit Unix-style line endings
Use Windows' default console window
Select all on the configure extras page

3. Install Python 2.7 to C:\mingw\Python27 (Download version 2.7.x not version 3.x). Select the following options:
Code:
Install for all users
On the Customize Python page, select the drive symbol next to "Python" at the top and select "Entire feature will be installed on local hard drive"

3a. If you want to compile using multiple cores (using -j<number of cores> i.e. -j4) download and install pywin32. (Download the 32 bit version of the latest build).

4. Install Scons to the default location (Select the latest version and download the zip file.) To install, navigate to the unzipped directory in a command prompt and run:
Code:
python setup.py install

5. Install Cmake to C:\mingw\Cmake. Use the Win32-x86 installer. When installing check "Add Cmake to the System PATH for all users".

6. Add C:\mingw\mingw32\bin to your system PATH. Also verify that C:\mingw\Python27, C:\mingw\Python27\Scripts, C:\mingw\Cmake\bin, and C:\mingw\Git\cmd are already all in your path.

7. Install mingw-get to C:\mingw\mingw32. Uncheck "...Also install support for the graphical user interface" when installing. NOTE: The installer doesn't automatically close when done.

8. Run C:\mingw\mingw-w64.bat. Once it opens, run:
Code:
mingw-get install mingw32-make mingw32-pthreads-w32

9. Download Physfs 3.0.1 and extract it to C:\mingw\. Open up mingw-w64.bat and cd to the extracted directory. Run the following (pressing enter after each line):
Code:
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/mingw/mingw32
mingw32-make install

10. In mingw-w64.bat cd to /mingw. Run the following (pressing enter after each line):
Code:
git clone https://github.com/pkgconf/pkgconf
cd pkgconf
mkdir build
cd build
cmake -G "MinGW Makefiles" -DSYSTEM_INCLUDEDIR=/mingw/mingw32/include -DSYSTEM_LIBDIR=/mingw/mingw32/lib -DCMAKE_INSTALL_PREFIX:PATH=/mingw/mingw32 ..
mingw32-make install

11. Save the following as C:\mingw\mingw32\lib\pkgconfig\sdl.pc (You may have to create the pkgconfig directory):
Code:
# sdl pkg-config source file

prefix=c:/mingw/mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sdl
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Version: 1.2.15
Requires:
Conflicts:
Libs: -L${libdir}  -lmingw32 -lSDLmain -lSDL  -mwindows
Libs.private: -lmingw32 -lSDLmain -lSDL  -mwindows  -liconv -lm -luser32 -lgdi32 -lwinmm -ldxguid
Cflags: -I${includedir}/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main

12. Save the following as C:\mingw\mingw32\lib\pkgconfig\sdl_mixer.pc:
Code:
# sdl_mixer pkg-config source file

prefix=c:/mingw/mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SDL_mixer
Description: Mixer library for Simple DirectMedia Layer
Version: 1.2.12
Libs: -L${libdir} -lSDL_mixer
Cflags: -I${includedir}/SDL

13. Download SDL 1.2 Mingw32 Devel (On the bottom of that page). Extract it and copy the contents of the lib, include, and bin folders to C:\mingw\mingw32\lib, C:\mingw\mingw32\include and C:\mingw\mingw32\bin respectively. NOTE: You don't have to copy the ._* files.

14. Download SDL_Mixer 1.2 Devel VC (The 3rd download under "Windows" on that page). Extract it and copy the contents of the include folder to C:\mingw\mingw32\include\SDL, and the contents of lib\x86 to C:\mingw\mingw32\lib.

15. Download LibZ and extract it to C:\mingw. (Links for the source code are about halfway down the page).

16. In mingw-w64.bat cd to the extracted libz directory and run the following (pressing enter after each line):
Code:
mkdir build
cd build
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/mingw/mingw32 ..
mingw32-make install

17. Download LibPNG and extract it to C:\mingw. (The source code links are in the yellow table).

18. In mingw-w64.bat cd to the extracted lpng directory and run the following (pressing enter after each line):
Code:
mkdir build
cd build
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/mingw/mingw32 ..
mingw32-make install

19. In mingw-w64.bat, cd to C:\mingw and run:
Code:
git clone https://github.com/dxx-rebirth/dxx-rebirth

20. cd into the newly created "dxx-rebirth" directory and run
Code:
scons.py CXX=/mingw/mingw32/bin/i686-w64-mingw32-g++ PKG_CONFIG=/mingw/mingw32/bin/pkgconf.exe RC=/mingw/mingw32/bin/windres host_platform=win32 -j4

You're all done! You should find the .exe files in the d1x-rebirth and d2x-rebirth folders. If you have any issues with any steps in this process, let me know and I'll try and help! Smile

Note: To compile a software-rendered build, just add opengl=0 to the scons command above. To build for Windows XP add CPPFLAGS="-D_WIN32_WINNT=0x501" (This disables IPV6 support. More info here). For more compile-time options see INSTALL.markdown

Note 2: if you get an error that physfs.h is unusable, edit the following line in C:\mingw\mingw32\include\physfs.h:
Code:
#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))

Change it to read:
Code:
#elif ((__GNUC__ >= 3) && (!defined __EMX__) && (!defined sun))

I've reported this issue upstream, so hopefully it's fixed soon.
Reply
#2
This makes me super Excited. As soon as you fix the directions, I am compiling this baby.
Reply
#3
OK, these should be good!

Let me know if you run into any issues Smile
Reply
#4
The only minor issue with the steps is 17, you actually want to extract the SDL_mixer.h file into C:\Git\mingw64\include\SDL, instead of extracting the include folder from the archive into the C:\Git\mingw64\include folder.

That being said, time to work on DescentRPG >Big Grin (The way I've always wanted to play Descent, anyways).
Reply
#5
Thanks! I updated the instructions Smile
Reply
#6
I've just finally got a working dev environment again using Windows!

I've posted the instructions, but I wanted to check... @Kp: would you prefer the builds be compiled with posix or win32 threads, and with sjlj or dwarf exception handling? Currently they're set to posix and dwarf.
Reply
#7
I don't use the Windows environment enough to have a meaningful opinion on either of those points.
Reply
#8
OK, sounds good!

Official builds are now (finally) updated!

Another question: should the official builds have debug=1 enabled? I think you @Kp may have answered that before, but I don't remember.
Reply
#9
They should not. You could provide a secondary build with it enabled, but for normal play, users definitely want debug=0. Among other things, debug=1 enables Int3 to raise debugger traps. For non-developers, that's nothing but pain with no upside. The only reason users might want a debug=1 build is that it also enables some level-designer-related cheats, like pausing robots, forcing level self-destruct, and granting the ship all weapons.
Reply
#10
I'm running into issues compiling on a Win10 box. I've been following the instructions and everything worked without errors until the very last step:

Code:
scons: Reading SConscript files ...
===== D1X-Rebirth v0.59.100 0.60.0-beta2-153-g12b57e84e6f2* =====
===== D2X-Rebirth v0.59.100 0.60.0-beta2-153-g12b57e84e6f2* =====
DXX-Archive.3: compiling on 'win32'/None for 'win32' into .
DXX-Archive.3: checking version of C++ compiler '/mingw/mingw32/bin/i686-w64-mingw32-g++' ... 'i686-w64-mingw32-g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 6.4.0'
DXX-Archive.3: checking path to assembler ... 'C:/mingw/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/as.exe'
DXX-Archive.3: checking version of assembler 'C:/mingw/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/as.exe' ... 'GNU assembler (GNU Binutils) 2.28'
DXX-Archive.3: checking path to linker ... 'C:/mingw/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/ld.exe'
DXX-Archive.3: checking version of linker 'C:/mingw/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.4.0/../../../../i686-w64-mingw32/bin/ld.exe' ... 'GNU ld (GNU Binutils) 2.28'
DXX-Archive.3:  CXX: '/mingw/mingw32/bin/i686-w64-mingw32-g++'
DXX-Archive.3:  CPPDEFINES: ['_WIN32', 'WIN32_LEAN_AND_MEAN', ('PHYSFS_DEPRECATED', '')]
DXX-Archive.3:  CPPPATH: ['common/include', 'common/main', '.']
DXX-Archive.3:  CPPFLAGS: ['-Wno-sign-compare']
DXX-Archive.3:  CXXFLAGS: ['-g', '-O2', '-ftabstop=4', '-Wall', '-Werror=extra', '-Werror=format=2', '-Werror=missing-braces', '-Werror=missing-include-dirs', '-Werror=uninitialized', '-Werror=undef', '-Werror=pointer-arith', '-Werror=cast-qual', '-Werror=missing-declarations', '-Werror=redundant-decls', '-Werror=vla', '-funsigned-char']
DXX-Archive.3:  LIBS: None
DXX-Archive.3:  LINKFLAGS: ['-mwindows']
DXX-Archive.3:  RC: '/mingw/mingw32/bin/windres'
DXX-Archive.3:  RCFLAGS: []
DXX-Archive.3:  $CCACHE_PREFIX: None
DXX-Archive.3:  $DISTCC_HOSTS: None
DXX-Archive.3: checking whether C++ compiler and linker work...yes
DXX-Archive.3: checking whether C++ compiler accepts -std=gnu++14...yes
DXX-Archive.3: checking endian to use...little
DXX-Archive.3: checking whether to enable word alignment fixups...no
DXX-Archive.3: building with OpenGL
DXX-Archive.3: checking whether to enable release options...yes
DXX-Archive.3: checking whether to enable memory allocation tracking...no
DXX-Archive.3: checking whether to enable level editor...no
DXX-Archive.3: checking whether to enable IPv6 support...no
DXX-Archive.3: checking whether to enable multiplayer over UDP...yes
DXX-Archive.3: checking whether to enable UDP game tracker...yes
DXX-Archive.3: checking how to format screenshots...png
DXX-Archive.3: checking libpng pkg-config libpng
DXX-Archive.3: using pkg-config at discovered path /mingw/mingw32/bin/pkgconf.exe
DXX-Archive.3: reading libpng version from ('/mingw/mingw32/bin/pkgconf.exe', '--modversion', 'libpng')
DXX-Archive.3: libpng version: '1.6.35'
DXX-Archive.3: reading libpng settings from ('/mingw/mingw32/bin/pkgconf.exe', '--cflags', '--libs', 'libpng')
TypeError: must be encoded string without NULL bytes, not str:
  File "C:\mingw\dxx-rebirth\SConstruct", line 5002:
    main(register_program)
  File "C:\mingw\dxx-rebirth\SConstruct", line 4975:
    ''.join(['%s:\n%s' % (d.program_message_prefix, d.init(substenv)) for d in dxx])
  File "C:\mingw\dxx-rebirth\SConstruct", line 4615:
    DXXProgram.static_archive_construction[user_settings.builddir] = archive = DXXArchive(user_settings)

  File "C:\mingw\dxx-rebirth\SConstruct", line 4283:
    self.configure_environment()
  File "C:\mingw\dxx-rebirth\SConstruct", line 4310:
    getattr(conf, k.name)()
  File "C:\mingw\Python27\scons-3.0.1\SCons\SConf.py", line 659:
    ret = self.test(context, *args, **kw)
  File "C:\mingw\dxx-rebirth\SConstruct", line 1166:
    e = self.check_libpng(context)
  File "C:\mingw\dxx-rebirth\SConstruct", line 1145:
    successflags = self.pkgconfig.merge(context, self.msgprefix, self.user_settings, 'libpng', 'libpng', _guess_flags)
  File "C:\mingw\dxx-rebirth\SConstruct", line 371:
    k:v for k,v in get_dictionary_item_view(context.env.ParseFlags(' ' + StaticSubprocess.pcall(cmd).out.decode()))
  File "C:\mingw\Python27\scons-3.0.1\SCons\Environment.py", line 800:
    do_parse(arg)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Environment.py", line 730:
    dict['LIBS'].append(self.fs.File(arg))
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 1356:
    return self._lookup(name, directory, File, create)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 1335:
    return root._lookup_abs(p, fsclass, create)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2367:
    dir_node = self._lookup_abs(dir_name, Dir)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 2372:
    result.diskcheck_match()
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 1581:
    "File %s found where directory expected.")
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 377:
    return self.func(*args, **kw)
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 385:
    result = predicate()
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 713:
    st = self.stat()
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 687:
    try: result = self.fs.stat(self.get_abspath())
  File "C:\mingw\Python27\scons-3.0.1\SCons\Node\FS.py", line 1097:
    return os.stat(path)

I don't really see any escaping issues. My PATH is:
C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\OpenVPN\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Vagrant\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\mingw\mingw32\bin;C:\mingw\Python27;C:\mingw\Python27\Scripts;C:\mingw\Cmake\bin;

I checked if \n in SConstruct line 4975 needs to be \\n but that doesn't seem to be the case. 

I also checked the output of pkgconf:

Code:
C:\mingw\dxx-rebirth>/mingw/mingw32/bin/pkgconf.exe --cflags --libs libpng
-IC:/mingw/mingw32/bin/../include/libpng16 -IC:/mingw/mingw32/bin/../include -LC:/mingw/mingw32/bin/../lib -lpng16 -lz

I'm out of ideas unfortunately, and would appreciate any help!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)