[FIX] Compiling Cataclysm-DDA experimental with mingw32 on Windows 7 X64

This is about a few fixes I found to make this work, rather than looking for help.

On this page, the first section is mingw32 with msys
http://www.wiki.cataclysmdda.com/index.php?title=How_to_compile

This works for the most part, if you follow it to the letter (For example, at one point I was incorrectly typing PATH=$PATH:blahblah instead of export PATH=$PATH:blahblah, and msys returned no errors about it) but it requires some alterations. (Also make sure to use proper capitalization when exporting the path.)

Make sure not to miss that cdda deps zip. You actually really need that.

First step, Ignore “Fixing the Makefile” section. The makefile is already fixed. The major issue is that the fix was moved into a makefile option. You have to additionally use “DYNAMIC_LINKING=1” in the command line in addition to NATIVE=win32 and TILES=1.

Second step, go into the directory you downloaded the git of catadda to, go into the src directory and edit sdltiles.cpp
On line 32 (after #include <windows.h>), you need to insert a new line and add #include <shlwapi.h>
, then, two lines down from that, change “#define strcasecmp strcmpi” to #define strcasecmp StrCmpI"

The reason is twofold: 1. For some reason g++ is being really strict about the capitalization, and 2. StrCmpI is a depreciated posix function. shlwapi.h contains the definitions for the use of this function.

These fixes should allow you to properly compile cataclysm.

In my efforts to figure out the above, I also ended up getting the libraries from this page http://gnuwin32.sourceforge.net/packages.html for a few of the dependancies. You shouldn’t need them if you’re using DYNAMIC_LINKING=1, but I’ll mention it here incase my steps don’t work.

ALSO, if you want to use make clean properly or just want to compile the non-tiles version, you need to get ncursesw5 developer stuff. I found a working set by downloading mingw32-20130623_widec_shared_ada.7z from https://sites.google.com/site/dsfbworks/ncurses-works and extracting it all to the mingw32 root directory.

Also at some point in my efforts to debug this, I ended up needing pkg-config somehow. I don’t remember the situation and I don’t think it’s relevant to compiling cataclysm-dda, but if you ever need it I found that http://sourceforge.net/projects/pkgconfiglite/ this version works just fine.

[quote=“Midaychi, post:1, topic:7240”]This is about a few fixes I found to make this work, rather than looking for help.
…[/quote]

Well that’s good. Thanks moderators, I saw that. I post a way to get around compiling this that you guys wouldn’t have ever figured out, and you go ahead and edit my post to make me look like a dumbass.

In-fact, I seem to remember ASKING for help, and Kevin’s lapdog telling me basically that “I don’t know, it must be on your end, because ‘Myself and countless other unnamed people can compile it just fine with mingw32.’”

ANYWAYS, I hope this helps people who’ve been having problems. I’m out.

???

Not entirely sure I was entirely awake or coherent when I wrote that. I saw some weird grammar I put in but forgot about, thought it was some admin ninja-editing and giving me passive aggressive snark, and made a ragequit post.

I guess that happens after about a weeks worth of trying to figure this out, so I’m sorry for being a random dick. You head coder guys are jerks but good coders, and cataclysm-dda is the kind of game that benefits from jerk head coders.

Anyways the above does work and hasn’t given me any errors so far, and probably allows the codeblocks version to compile fine as well if you use the mingw32 compiler and set up the directories/path properly.

Thanks for posting what you’ve found.

I don’t know what’s different about your system compared to all the others where the game compiles without your workarounds and fixes, but I’m not sure what you expect people to do about it if they can’t reproduce your problem and don’t know what the fix is.

To make SDL to compile on Windows 7 x64 with Code::Blocks I did following steps:

  1. I used Release - SDL configuration - all changes in Project Build Options should be done for specific configuration, not for entire project!
  2. added missing SDLTILES into Project Build Options->Compiler settings->#defines (other tiles configurations had it already)
  3. created WinDepend directory in project root (it is defined in .gitignore already)
  4. copied these files:

[ul][li]content of SDL2-devel-2.0.3-VC.zip\SDL2-2.0.3\lib\x86 into WinDepend[/li]
[li]content of SDL2-devel-2.0.3-VC.zip\SDL2-2.0.3\include into WinDepend\SDL2[/li]
[li]content of SDL2_ttf-devel-2.0.12-VC.zip\SDL2_ttf-2.0.12\lib\x86 into WinDepend[/li]
[li]content of SDL2_ttf-devel-2.0.12-VC.zip\SDL2_ttf-2.0.12\include into WinDepend\SDL2[/li]
[li]content of SDL2_image-devel-2.0.0-VC.zip\SDL2_image-2.0.0\lib\x86 into WinDepend[/li]
[li]content of SDL2_image-devel-2.0.0-VC.zip\SDL2_image-2.0.0\include into WinDepend\SDL2[/li][/ul]

  1. replaced paths in Project Build Options->Search directories with path WinDepend
  2. replaced paths in Project Build Options->Linker settings with these:

[ul][li]WinDepend\SDL2.lib[/li]
[li]WinDepend\SDL2_image.lib[/li]
[li]WinDepend\SDL2_ttf.lib[/li]
[li]WinDepend\SDL2main.lib[/li][/ul]

  1. last missing piece for successful compilation was
Second step, go into the directory you downloaded the git of catadda to, go into the src directory and edit sdltiles.cpp On line 32 (after #include ), you need to insert a new line and add #include , then, two lines down from that, change "#define strcasecmp strcmpi" to #define strcasecmp StrCmpI"
So thanks for that! :)

Now, the only problem is that change to strtiles.cpp in in git hub as Uncommited change…

[quote=“Kevin Granade, post:5, topic:7240”]Thanks for posting what you’ve found.

I don’t know what’s different about your system compared to all the others where the game compiles without your workarounds and fixes, but I’m not sure what you expect people to do about it if they can’t reproduce your problem and don’t know what the fix is.[/quote]

I think maybe g++ updated or something and changed how it handled certain dated posix functions. I bet if I downgraded g++ to a much earlier version, that it’d compile fine.

Either that or windows.h changed. Either a windows 7 update changed it or my paths changed. I did see StrCmpI listed as a depreciated posix function on the msdev references when I was searching the compile error.

Since this thread may as well act as a sort of a repository of knowledge regarding to compiling CDDA on Windows, here’s another bit.

If you’ve updated SDL2 to version 2.0.3, know that it’s got a bugged SDL_platform.h. It should be fixed sometime, but until then in order to compile you’ll need the updated version, here: https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h

I cant get it to work at all.

I need a real noob tutorial for codeblock set up pn win7 64 bit.

Im trying to compile tiles version of CDDA exeprimentles :frowning:

Please help me.
Damn it I am going bloody crazy here :frowning:

You need to follow instructions in this quote:

[quote=“Robik, post:6, topic:7240”]To make SDL to compile on Windows 7 x64 with Code::Blocks I did following steps:

  1. I used Release - SDL configuration - all changes in Project Build Options should be done for specific configuration, not for entire project!
  2. added missing SDLTILES into Project Build Options->Compiler settings->#defines (other tiles configurations had it already)
  3. created WinDepend directory in project root (it is defined in .gitignore already)
  4. copied these files:

[ul][li]content of SDL2-devel-2.0.3-VC.zip\SDL2-2.0.3\lib\x86 into WinDepend[/li]
[li]content of SDL2-devel-2.0.3-VC.zip\SDL2-2.0.3\include into WinDepend\SDL2[/li]
[li]content of SDL2_ttf-devel-2.0.12-VC.zip\SDL2_ttf-2.0.12\lib\x86 into WinDepend[/li]
[li]content of SDL2_ttf-devel-2.0.12-VC.zip\SDL2_ttf-2.0.12\include into WinDepend\SDL2[/li]
[li]content of SDL2_image-devel-2.0.0-VC.zip\SDL2_image-2.0.0\lib\x86 into WinDepend[/li]
[li]content of SDL2_image-devel-2.0.0-VC.zip\SDL2_image-2.0.0\include into WinDepend\SDL2[/li][/ul]

  1. replaced paths in Project Build Options->Search directories with path WinDepend
  2. replaced paths in Project Build Options->Linker settings with these:

[ul][li]WinDepend\SDL2.lib[/li]
[li]WinDepend\SDL2_image.lib[/li]
[li]WinDepend\SDL2_ttf.lib[/li]
[li]WinDepend\SDL2main.lib[/li][/ul]

  1. last missing piece for successful compilation was
Second step, go into the directory you downloaded the git of catadda to, go into the src directory and edit sdltiles.cpp On line 32 (after #include ), you need to insert a new line and add #include , then, two lines down from that, change "#define strcasecmp strcmpi" to #define strcasecmp StrCmpI"
So thanks for that! :)

Now, the only problem is that change to strtiles.cpp in in git hub as Uncommited change…[/quote]

I’m gonna break it down for a “real noob” level :slight_smile:

Before you start you need to checkout the code from the repository, for instance using GitHub’s handy app, or maybe by just downloading it from the site here: GitHub - CleverRaven/Cataclysm-DDA: Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world. (big friendly “download ZIP” button)

You’re also going to need Code::Blocks, obviously. Get it here: https://www.codeblocks.org/downloads/binaries/ , make sure to get the version with the included mingw compiler.

Open the project file in the directory where you’ve downloaded the source to.

For steps 1 and 2 of the above process, open Project->Build Options… from the CB menu strip. In the window, pick “Release - SDL” on the left side, and the “Compiler Settings”->“#defines” tabs on the right side. Add “SDLTILES”, on a new line and without quotes, to the list of strings you see there.

Step 3 should probably not be explained additionally, just create a folder called “WinDepend” in the same directory as the Cataclysm project file. In preparation for step 4, also create an “SDL2” folder inside the “WinDepend” folder.

Files for step 4 are here:
SDL2-devel-2.0.3-VC.zip - https://www.libsdl.org/download-2.0.php (under Development Libraries, for 32-bit Windows)
SDL2_ttf-devel-2.0.12-VC.zip - https://www.libsdl.org/projects/SDL_ttf/ (under Development Libraries)
SDL2_image-devel-2.0.0-VC.zip - https://www.libsdl.org/projects/SDL_image/ (under Development Libraries)

From within each of those archives, any files under the \lib\x86 path are to be extracted directly into the WinDepend folder.
Any files under the \include folder must be extracted to the WinDepend\SDL2 folder.

Additionally, as I noted above, you will need a replacement SDL_platform.h file from here: https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h . Download it and put it in the WinDepend\SDL2 folder after you’re done with the others.

For step 5, open the same Project->Build Options… window as in step 2, and select the same “Release - SDL” entry on the left. On the right, select the “Search Directories” tab. It has three sub-tabs, you need to check two - “Compiler” and “Linker”. Inside each, there should be only one remaining entry, and it should read simply “WinDepend” - create it, and delete all others.

For step 6, in the same window and with “Release - SDL” still selected on the left, select the “Linker Settings” tab on the right. You should see a list of several paths there. Either edit them all, or delete them after adding the new entries, but in the end there should be four entries in that list, reading “WinDepend\SDL2.lib”, “WinDepend\SDL2_image.lib”, “WinDepend\SDL2_ttf.lib”, and “WinDepend\SDL2main.lib”, all without quotes.

For step 7, you’ll need to open one of the source files. With the Cataclysm project open, you’ll see on the left a list showing the files in the Cataclysm project. If you don’t, hit Shift+F2, or check the View->Manager option from the menu strip. The file you need is under Cataclysm\Sources\src\sdltiles.cpp . Open that file, and scroll down to lines 32-35, which should be saying

#include <windows.h> #ifndef strcasecmp #define strcasecmp strcmpi
(unless you checkout the code after it’s been fixed)
You need to make that section look like this instead, expanding it to four lines:

#include <windows.h> #include <shlwapi.h> #ifndef strcasecmp #define strcasecmp StrCmpI

Note the capitalization on the last line. After that, you are pretty much done. Make sure you select the “Release - SDL” profile on the drop-down next to the compile buttons on the main screen (top center of the Code::Blocks window, right under the menu strip), otherwise all the variables you’ve been setting won’t apply.

If you still have problems after doing all that, post the exact error messages you’re getting here, and we’ll try to sort it out. :slight_smile:

oh wow thanks so so much going to follow this right away :slight_smile:
thank you

No problem. :slight_smile:

I’m probably forgetting a step or three somewhere in the CodeBlocks setup, it’s been pretty long since I did it myself and I don’t remember what I’ve been actually doing, or at least what I’ve been doing that actually helped. :stuck_out_tongue:

this is fantastic im only getting one error whice is way better than before LOL

error is

-------------- Build: Release -SDL in Cataclysm (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wextra -Wall -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -std=c++11 -Os -O2 -DTILES -DRELEASE=1 -DSDLTILES -IWinDepend -c C:\CDDA\src\sdltiles.cpp -o obj\Release\src\sdltiles.o
In file included from C:\CDDA\src\cata_tiles.h:10:0,
from C:\CDDA\src\sdltiles.cpp:15:
WinDepend/SDL2/SDL_ttf.h:30:17: fatal error: SDL.h: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Well, the error’s pretty self-explanatory. Check the contents of your WinDepend\SDL2 folder. Is there an “SDL.h” file there?

yep is in there for sure its in

C:\CDDA\WinDepend\SDL2

Hrm.

Well, I’ve no idea where else I have this defined, but I suppose you could add a “WinDepend\SDL2” folder to your Search Directories. See the instructions post, step 5, and add that path to the Compiler search paths. SDL_ttf.h tries to include an “SDL.h”, unlike the CDDA code that always uses the SDL2 path. Not sure what’s up here, but it might work.

Well thanks so much I got it working I am not sure if linking it to SLD2 fixed it or just doing a complete rebuild fixed it but yep it all works and compiles :slight_smile:

What I have done is made a back up of WinDepend incase I delete it or if I want to install codeblocks on a diff computer.

If some one wants me to upload my WinDepend folder whice will save every one setting it up let me know.

But off course this is all thanks to

Sean Mirrsen

EDIT

Just one issue

I can run the version I created VIA CodeBlocks

BUT

If I try to run the EXE from the CDDA folder it says cant find SDL2.DLL

Well, yes. The linker takes care of the libraries if you run from the compiler, they are in the WinDepend folder. Statically linking all those libraries involves a little more codemongering than I’m willing to undertake, or at least that’s I’ve been led to believe. So if you want to run your compiled version on your own, you’ll need to copy all the DLL files from WinDepend into the same folder as your executable.

Hi again Sean Mirrsen

I really appriciate the help on this truly do :slight_smile:

I just downloaded the latest experimentle version to have a go at compiling that.
But I seem to have made a terrible mistake LOL I have lost all the settings I did under Release SDL :frowning:

How is the correct way to import a new release? because codeblocks cant pull in Github builds as far as I know.

Thanks again kind sir

I don’t think there’s any way to keep your project file if you re-update from the source. You’ll have to re-set the paths and variables every time you do it. At least I had to, this time around. Ideally, if you are contributing instead of just doing mods for yourself, you’re not going to need to update from the source too often.

But if you want to have a proper setup, you’ll need a GitHub account, and the GitHub application. Once you have both, fork the repository to your account (the “Fork” button in the top right of the project page). Open the application and log into your account, and it will download the repository to your PC. Once you’ve done that, you’re going to want to start a separate branch for your changes, so that you can update the master branch without losing your changes. To do that, once you’ve opened the repository in the program, there is a “master” line in the top of the main screen. Click that to open the branches list, and it will prompt you to enter a name into the provided text field to create a new branch. Once you’ve done that, feel free to mess around in the code, and you’ll always have the original source saved in the master branch.