Last night I spend multiple hours trying to get a non-broken CSFML build ready, which requires to have import libraries for MSVC and GCC that both depend on the same DLL. This works because the import library only points to the symbols that are in the DLL, thus acts as sort of instruction how to use the DLL.
Update 29.09.2014: As pointed out by Anastasia Kazakova in the comments, CLion’s EAP has received an update which added native support for MinGW-w64!
In the past few days, I’ve seen CLion mentioned on multiple locations including the SFML forum. CLion is a new IDE developed by JetBrains for CMake based projects, it supports multiple languages and can be further extended with plugins. Some might recognize the interface since it’s very similar to JetBrains’ popular Java editor IntelliJ IDEA.
Personally I haven’t really looked at the IDE in-depth, since JetBrains is the creator of the allegedly awesome ReSharper tool for Visual Studio – which I’ve never used – the IDE itself should provide some pretty decent refactoring capabilities. Last I checked out Qt Creator, I was a bit disappointed at the sluggish CMake integration; this at least seems to work a lot better with CLion. However maybe Qt Creator upped their game since then as well.
This post however shouldn’t really be about introducing/promoting CLion and maybe some or many of you who somehow find this post already know what CLion is, instead this should actually be a short tutorial on how to use a compiler of the MinGW-w64 family with CLion.
For whatever reasons the developers at CLion apparently didn’t get the memo, that the original MinGW has been relatively abandoned and most of the user base has moved on to the MinGW-w64 project, which originally was created to develop a 64-bit compiler, but now supports both architectures. As such CLion currently only officially supports the vanilla MinGW. As a MinGW user for many years, the fact that CLion only wanted to recognize the original MinGW as compiler seemed rather odd, since the differences in using either a MinGW or a MinGW-w64 version nearly doesn’t exist. When I ran ProcMon and tracked what in the filesystem CLion accessed, I noticed that it checks for the existence of include/_mingw.h. By providing such a file in your MinGW-w64 directory structure you can trick the compiler into accepting it as MinGW compiler.
Here are the few steps to make it work:
- Get your MinGW-w64 compiler installed somewhere.
- Create a file with the path [MinGW-w64 dir]/include/_mingw.h and the content shown below.
- Point CLion to your [MinGW-w64 dir] and watch how CLion recognizes your MinGW setup.
#ifndef __MINGW_H #define __MINGW_H #define __MINGW32_VERSION 3.20 #define __MINGW32_MAJOR_VERSION 3 #define __MINGW32_MINOR_VERSION 20 #define __MINGW32_PATCHLEVEL 0 #endif /* __MINGW_H */
Disclaimer: CLion is still in an Early Access Program and may change any day. This trick worked for me, but there’s still a chance that it might not work for you.
To end this write up, here’s the introduction video from JetBrains on CLion – it was posted on their blog.
I finally got around to rewrite my build scripts again. But first let’s see what has happened in the past. As my notebook got stolen a few month back, I’ve lost the original scripts. Then I tried to write a “smarter” and more “modular” system, which ended up being just another mess after all and limiting me for the correct compilation of the Thor libraries. In between the last update and today, SFML has finally seen its long, very long, extremely long, awaited release, which also included an update to SFML’s website and the choice of the final logo. From now on I think many people will just stick to the official 2.0 release and wait for the next version, thus I didn’t feel obligated to keep the Nightly Builds update for every new commit and let it slide for a while. Till yesterday, when I decided to rewrite all the scripts and ended up doing so not only for SFML, but also for Thor, but since GCC 4.8 has been released in that timespan as well, I decided to switch out some compilers. In the past I’ve been quite happy with the rubenvb builds and I believe they are still very good, but I decided to switch to the MinGW Builds. On the search for GCC 4.8 MinGW versions, I’ve stumbled across nuwen.net, which is a project, where someone is keeping his development environment up-to-date with the public. Thus you get his own MinGW version, plus a few quite popular libraries pre-compiled. I believe this could be quite nice for people, that don’t feel like recompiling stuff every other week, which is why I’m supporting that project with my SFML builds. As a final note, I’m totally not a fan of the TDM builds, mainly because their default behavior regarding static linking goes against all the other GCC versions, but since it’s still the one compiler Code::Blocks ships with, I’ll keep it in the list for now.
Enjoy and as always, I’m very open for feedback!