I have seen some people struggling with compiling Colobot using Visual Studio, but when I run cmake I get an error: "Your C++ compiler doesn't seem to support C++11. Supported compilers at this time are GCC 4.6+ and clang." Does that mean that Colobot uses C++11 features which are only available in GCC and clang, but not in other compilers (like MSVC)? I wanted to try to build the project using Visual Studio Community 2013, but I don't want to waste time struggling because of the compiler itself not supporting some necessary features for building.
It might be just that it doesn't know how to enable C++11 features in the compiler, or maybe the compiler doesn't support everything that's needed. I guess @piotrdz would know better.
Take a look at this fragment of code: https://github.com/colobot/colobot/blob/...#L117-L135
I've found this: http://cpprocks.com/c1114-compiler-and-l...-shootout/
I don't know which features are needed from C++11 standard, but it seems MSVC still lack from supporting them. Maybe we could rewrite some parts of code, but:
1) if we'll have separate versions of code to gcc/clang and separate to msvc, some parts of code will be doubled, some issues could appear only to owners of specific compiler, what could make it more difficult to debug. And there will be need of copying same code two times.
2) if we'll rewrite current code to more universal - well, I don't know, it may be harder to develop, or have worst optimalisation.
Initially we focused on porting to Linux, so support for GCC and Clang was first priority. Then, adding Windows support was easier using MinGW and MXE, as GCC was already supported. The problem with MSVC was until recently poor support for C++11, especially two features we use: range-based for loops and initializer lists. With latest updates to MSVC 2013, it seems all we need is supported, so we can finally add it as supported. The remaining problem is getting it to compile with all necessary libraries. I could give it a try sometime later and see if it really works.
04-25-2015, 09:04 PM (This post was last modified: 04-25-2015, 09:11 PM by Simbax.)
Well, Colobot uses not implemented features.
I managed to install all necessary dependencies except po4a (it took me about 3 hours and I encountered some problems, but I think I can make a proper package) and CMake successfully generated VS2013 project files. I opened a solution and tried to build it. Even music is converted without problems, but some parts of code give errors.
In app.h:
Code:
#include <unistd.h>
#include <getopt.h>
unistd.h and getopt.h are for UNIX-based systems. However, I have found these files in the Internet (their Win32 versions) and put them along the dependencies and this error no longer occured. But it's the last error that can be fixed without changing the code.
In the same file:
Code:
usleep(20000); // should still give plenty of fps
usleep function doesn't exist on Windows. There is an ugly workaround:
04-26-2015, 09:52 PM (This post was last modified: 04-26-2015, 09:52 PM by piotrdz.)
Well, you're right, we still have some dependencies to Unix utilities. We should not be using unistd.h and getopt.h directly, but provide the necessary functions via SystemUtils interface. The noexcept error could be fixed by providing an empty noexcept macro and the two remaining errors can be fixed with some rewriting of code. Some warnings are also worth to look at. I have some time today, so I should be able to fix it.
Still, such problems are pretty embarrassing for Microsoft, as C++11 standard is now almost 4 years old, yet their compiler still doesn't fully support it.
Update: I almost forgot just how much pain it is to compile something under Windows. But I finally got it to compile I will commit my fixes tomorrow as I'm too tired today.
(04-26-2015, 11:22 PM)tomangelo Wrote: So 0.1.5 will have support for MSVC 2010 or 2013?
Indeed it will as I've just committed my changes. I compiled the project successfully using MSVC 2013 with update 4, and I think this is the only version which works. I can also provide a link to download archive with necessary libraries. What still doesn't work is generation of translations in data submodule, as for this you need some minimum Unix environment (perl, bash, sed, etc.).
Unpack the zip file to some directory (f.e. C:\Dev\colobot-dependencies-msvc2013).
If you want to have music, copy bin\oggenc.exe file to a directory which is included in your PATH. If you won't do it and you have music submodule in your local repository, it will result in errors during installation.
Use cmake-gui or a command line in order to build Colobot to some directory (preferably colobot-repo\build).
Run cmake with at least these variables set:
Visual Studio 12 2013 generator (or newer if you have other version installed, don't know if it will work)
CMAKE_PREFIX_PATH = path to the directory where you unpacked colobot-dependencies-msvc2013
BOOST_STATIC = 1 (dynamic build for some reason doesn't work for me)
CMAKE_BUILD_TYPE = Release or Debug
You can also add other configuration variables of course.
Open generated colobot.sln file using Microsoft Visual Studio.
Change the configuration type from Debug to Release.
Right click on the solution in the Solution Explorer and set INSTALL to be built (in Configuration Properties.)
Build solution (F7).
Colobot will be probably installed to C:\Program Files\colobot. Copy there all DLL files from colobot-dependencies-msvc2013/DLLS.
Set all convert* projects to not be built for better future compilation times (you only need to convert them once, but Visual Studio would convert them every time which takes some time).
You can finally enjoy/test/develop the game with your own Windows build! (except translations...)
The package contains basically the same as Simbax's one, but I changed SDL_image to use libpng in one version. It should also work according to instructions above.