Windows compiling requirements
A list of things that you need to install in order to compile the OHRRPGCE source code on Windows.
Quickstart[edit]
You can ignore the rest of this page and just follow this checklist. NOTE: these instructions need retesting, some details may be incomplete.
(These instructions are for the FreeBASIC 1.09 release)
- Install Python 3. You should probably download the "Windows installer (64-bit)" for the latest version
- Probably any version of Python will work, even Python 2.x is supported
- While installing, make sure you check the checkbox that reads (something like) "Add to PATH"
- In a terminal, check that running python works. Ctrl-C to exit.
- In a terminal, run pip install SCons (pip is installed by Python. SCons is a Python package)
- Install 7zip if you don't already have it, to extract .7z files (which are a huge improvement over the 1980's .zip files)
- Download winlibs-mingw-w64-i686 (51MB) and extract it
- If you want you can get a 64-bit FB build instead, we don't support compiling the OHRRPGCE for win64 so you'll need to compile with `scons arch=32`
- Download and install [1]
- Edit the Windows PATH (see also Setting up your PATH on Windows). (In Windows 10, you can open the Start menu and search for "Environmental variables") You can edit either the User or System-wide path. Add the bin\ directory of the winlibs installation and the directory where fbc.exe was installed (probably C:\Program Files (x86)\FreeBASIC\).
- winlibs must be first, to override the gcc.exe packaged with FB! Otherwise you'll get errors about missing stdlib.h and stdarg.h
Now you only need the OHRRPGCE source code. You can download a zip file from Source, but if you intend to make changes to the code and submit your improvements it's highly recommended that you use git or svn to download the source. Using git:
- Install git from [2] (you probably want "64-bit Git for Windows Setup")
- In a terminal, cd to the directory where to create the ohrrpgce repository (e.g. C:/)
- Run git clone https://github.com/ohrrpgce/ohrrpgce.git
- Run cd ohrrpgce then scons to compile
You still won't be able to compile HSpeak or gfx_directx.dll. See futher down this page for those.
FreeBasic[edit]
You need the FreeBASIC compiler. Check the version and the release year carefully. If you want to compile older OHR versions, use a compiler that was available at the time of the release that you try to compile. That's because the different FreeBasic versions are incompatible to each other. If you get any errors regarding a specific command, but PATH is set up correctly and everything else is properly installed, try another compiler version.
There are quite a few alternative downloads for FB provided, in two main flavours: those compatible with MinGW, and those compatible with MinGW-w64.
Therefore please read Getting FreeBasic and the next section before deciding which version of FB to install.
Don't download (e.g.) "gcc-5.2.0-for-FB-win32-gengcc.zip for -gen gcc" from the FB Downloads page, as this includes only gcc.exe and a couple libraries. You need a more complete build of GCC which includes g++, the C++ compiler (see next section).
Euphoria for HSpeak (optional)[edit]
To compile hspeak you need Euphoria 4.0+ from http://openeuphoria.org/
MinGW C and C++ compilers[edit]
You need a copy of GCC. There are several distributions of GCC for Windows, including MinGW or mingw-w64. Win-builds does not work, as it is far too old. We support both MinGW (mingw.org) and MinGW-w64.
See also GCC toolchain choice on the FB wiki.
Beware! You need to install a version and distribution of GCC/MinGW which is compatible with the version of MinGW which the FB developers used to compile the build of FreeBasic you install. Otherwise you will get errors like:
C:\Program Files\FreeBASIC1.04\lib\win32/libfbmt.a(time_now.o):time_now.c:(.text+0x11): undefined reference to `_time32' C:\Program Files\FreeBASIC1.04\lib\win32/libfbmt.a(time_now.o):time_now.c:(.text+0x19): undefined reference to `_localtime32'
MinGW[edit]
The original MinGW (aka MinGW.org, mingworg) is split into different packages. The easiest way to install it is with the latest mingw-get-inst installer program in which you select which packages to install. Include the optional g++ package in your installation.
MinGW may appear to be a dead project because its website has hardly been updated in a decade, but its software repositories are kept up to date.
MinGW-w64[edit]
MinGW-w64 is a re-implementation of MinGW. It is NOT a 64-bit version of MinGW. It can compile both 32 and 64-bit Windows programs. In recent years it has become more popular than MinGW, so that some programs no longer even support compiling with MinGW.org. So you might prefer MinGW-w64 if you also want to compile other software.
For gfx_directx.dll (optional)[edit]
The following are needed only if you want to compile gfx_directx.dll. (A pre-compiled copy is included with the source code.)
Visual Studio[edit]
GCC can't be used to compile gfx_directx.dll. Install Visual C++. You don't need support for any other languages such as C# or any of the numerous extras that the installer includes. 2008, 2010, 2010 Express (and 2013 Express?) are known to work; all Express editions should work. Versions earlier than 2008 will probably work?
If you are using Visual C++ 2008 or earlier, you are probably missing stdint.h. Download a suitable header, for example, one of the ones linked here, and place it in the gfx_directx directory.
If Visual Studio isn't installed correctly then attempting to compile will use GCC, which will cause strange messages about unsupported commandline options.
Make sure that you are compiling using the "Visual Studio 20XX Command Prompt" and not the regular "cmd" command prompt, or you will see an error message about missing cl.exe
Windows SDK[edit]
You need the Windows SDK. Recent versions of Visual Studio include the Windows SDK (Visual Studio 2008 and later, and Visual Studio 2010 Express and later?) Different versions of Visual Studio support different versions of the SDK, so don't just download the latest SDK (see Q: What compiler toolset does a given Windows SDK support?.
The Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (v7.0) supports Visual Studio 2005 and later, on Win XP or later.
DirectX SDK[edit]
You can find the SDK at microsoft.com. As far as I know, any version of the SDK for DirectX 9 or later should work, because gfx_directx.dll does not use anything in the DirectX 9 extension library (which requires a special .dll).
After installing the SDK, the DXSDK_DIR environmental variable needs to be correctly set. It should be set automatically.
Libraries[edit]
You don't need to install any. The necessary header and library files (eg for SDL and SDL_mixer) are included with FreeBASIC and the OHRRPGCE source code.
SDL_mixer.dll and SDL2_mixer.dll[edit]
This documents how our builds of SDL_mixer.dll/SDL2_mixer.dll were compiled, which use non-default configuration in order to work around various SDL_mixer problems. You do not want to do this; it's a real pain. SDL{,2}_mixer.dll and win32/SDL{,2}_mixer.dll.a are included with the source code.
SDL{,2}_mixer.dll are both compiled statically linked to libogg, libvorbis, libvorbisfile, libmad, and libmodplug, and dynamically linked to SDL{,2}.dll, to greatly cut down the total file size and number of libraries. We compile without FLAC support to reduce filesize. Also, SDL_mixer is patched to enable mikmod and modplug loop points, and built with all symbols exported so we can call into the constituent libraries. win32/debug/SDL{,2}_mixer.dll are non-stripped copies of SDL{,2}_mixer.dll.
Cross-compiling with mxe[edit]
I compiled the libraries using mxe makefiles. See Cross-compiling for an introduction to mxe. First, grab my fork from https://github.com/rversteegen/mxe and then read the blurb at the top of src/sdl_mixer_ohrrpgce.mk for instructions what to do next. Unfortunately mxe will try to either link all libraries statically or dynamically, and to get what we want you will need to manually install SDL.dll/SDL2.dll. You can skip this part if you don't care to get a dll built just like the one we distribute.
Then you can run:
make MXE_TARGETS=i686-w64-mingw32.static sdl_mixer_ohrrpgce sdl2_mixer_ohrrpgce
On a clean check-out of mxe this compiles gcc, etc, which may take a couple hours so you might want to look into downloading a precompiled copy of mxe.
(If you use i686-w64-mingw32.shared as the target instead then libraries like libmad.dll won't be statically linked into the .dll).
Using mingw[edit]
If you want to compile on Windows using mingw, you can see the needed configure flags here and the patch to enable module loop points here (v1.2) or here (v2.0). You're on your own.