SFML community forums

Help => General => Topic started by: firstep on September 10, 2014, 04:50:08 am

Title: clion and sfml?
Post by: firstep on September 10, 2014, 04:50:08 am
I am using mac osx. I hate xcode and eclipse. They are super slow. Just wanna try the new jetbrains IDE for c++ named clion. Im not a c++ PRO and just only started learning it so i dont know how to integrate sfml in clion

Can you guys help me?

Thanks
Title: Re: clion and sfml?
Post by: Strelok on September 10, 2014, 07:36:51 am
One good thing to do would be learning how to configure projects with CMake as CLion uses it too :D
Title: Re: clion and sfml?
Post by: firstep on September 10, 2014, 10:06:53 am
One good thing to do would be learning how to configure projects with CMake as CLion uses it too :D

Do i need to learn Cmake then?
Title: Re: clion and sfml?
Post by: Strelok on September 10, 2014, 10:19:57 am
Well, it's a powerful tool that lets you set up your project in most of the popular IDEs and helps you a lot when building crossplatform applications.
Here's an example to work with SFML and CLion:

CMakeLists.txt (Documentation (http://www.cmake.org/cmake/help/v3.0/manual/cmake-commands.7.html))
cmake_minimum_required(VERSION 2.8)
project(forum CXX)
if(WIN32)
    set(SFML_ROOT "$ENV{PROGRAMFILES(x86)}/SFML") # You will probably have to change this
endif(WIN32)
set(CMAKE_BUILD_TYPE Release) #If you have problems check if you have SFML debug libraries or release libraries
find_package(SFML 2.1 COMPONENTS system window graphics REQUIRED)
include_directories(${SFML_INCLUDE_DIR} ${PROJECT_SOURCE_DIR})
set(SOURCE_FILES main.cpp   )
set(HEADER_FILES            )
add_executable(forum ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(forum ${SFML_LIBRARIES})
Your main.cpp
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "Test");
    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }
    }
    return 0;
}
YOU NEED THE DLLs TO RUN THE PROGRAM AFTER COMPILING IT!
Title: Re: clion and sfml?
Post by: jokoon on September 10, 2014, 02:23:40 pm
Yeah, heard of clion too, I wonder how good it is.

I'm tempted to use it, as I use both MSVC and xcode for the same code. XCode's autocomplete is slow (and I don't like XCode in general), and MSVC2012 doesn't support variadic templates. Since jetbrains support both clang and GCC and gdb, I guess it would be nice. I hope the debugger is as good as MSVC's.

I guess I'll try some day. Although I'm not sure if I'd pay for an IDE. If it's over 30 euros or 30 dollars I don't think I would buy it.

Any C++ jet brain user ?

First question, do you have to recompile SFML ? I guess not, since the SFML libs use stdlib++
Title: Re: Re: clion and sfml?
Post by: Strelok on September 10, 2014, 02:57:41 pm
Yeah, heard of clion too, I wonder how good it is.

I'm tempted to use it, as I use both MSVC and xcode for the same code. XCode's autocomplete is slow (and I don't like XCode in general), and MSVC2012 doesn't support variadic templates. Since jetbrains support both clang and GCC and gdb, I guess it would be nice. I hope the debugger is as good as MSVC's.

I guess I'll try some day. Although I'm not sure if I'd pay for an IDE. If it's over 30 euros or 30 dollars I don't think I would buy it.

Any C++ jet brain user ?

First question, do you have to recompile SFML ? I guess not, since the SFML libs use stdlib++
I've tried it this morning and it is still lacking a lot of features, I had hoped there would be a stronger CMake integration but you can't even tell the IDE to search for libraries as far as I can tell. You still have to write the CMake file yourself.
Title: Re: clion and sfml?
Post by: firstep on September 14, 2014, 08:14:05 am
Hi,

I cant see the clion option on cmake.

Can you teach me step by step if not too much?
Title: Re: Re: clion and sfml?
Post by: Strelok on September 14, 2014, 10:11:57 am
Hi,

I cant see the clion option on cmake.

Can you teach me step by step if not too much?
There's no need to generate project files for Clion. CLion use CMakeLists.txt as project file (and stores other stuff in .clion if I recall correctly). You only need to "open project" from the IDE and select the CMakeLists.txt file I wrote in a previous post.
Title: Re: clion and sfml?
Post by: georger on September 14, 2014, 03:15:44 pm
Yeah, heard of clion too, I wonder how good it is.

I'm tempted to use it, as I use both MSVC and xcode for the same code. XCode's autocomplete is slow (and I don't like XCode in general), and MSVC2012 doesn't support variadic templates. Since jetbrains support both clang and GCC and gdb, I guess it would be nice. I hope the debugger is as good as MSVC's.

I've been programming on Windows for a few years, used a number of IDEs/compilers, and in my opinion the debugger in Visual Studio is second to none. About the debugger in CLion: on Windows, it's good old gdb. So if you've ever used it in any other Windows IDE that supports GCC (Qt Creator, CodeLite, Code::Blocks) you know what to expect.

About CLion. I decided to give it a try, and found out, much to my dismay, that on Windows it only supports vanilla MinGW (http://youtrack.jetbrains.com/issue/CPP-668), which has been pretty stagnant as of late. I switched to TDM-GCC some time ago, and never looked back; I was really disappointed when I found out that CLion doesn't support it.

If you would like to use a single IDE on Windows and OS X, there are at least two options that cost $0: Qt Creator and CodeLite.

I'll talk a bit about Qt Creator. I've been trying it these last few days, and I like it; about the only thing I dislike is that project setup requires quite a bit of manual tinkering with the project file (later I learned Laurent Hammerchmidt wrote a tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Compile-and-Link-SFML-with-Qt-Creator) for using SFML with Qt Creator) - in my view, a good IDE should automate and/or offer a GUI for most project settings, and shield you from having to learn more about the build system than you probably ever wanted to know, period. And since the project file is actually a configuration file for the project's build system (Qt Creator supports several of them, the default being Qt's qmake), should you decide you want/need to switch build systems (e.g. from qmake to CMake), you'll have to re-write your project file almost from scratch - and of course you'll most likely spend a fair bit of time becoming familiar with the build system, learning its syntax and quirks, and doing test builds, instead of working on your project...
Laurent's tutorial covers project setup with qmake. I read a bit about CMake and Qt's new qbs build system, and decided to try qbs; I found it to be simple enough to configure, and powerful/elegant/flexible enough to add custom functionality, like copying the DLLs to the output folder after building.

EDIT: Misattributed wiki page authorship. Fixed.
Title: AW: Re: clion and sfml?
Post by: eXpl0it3r on September 14, 2014, 03:27:28 pm
...(later I learned Laurent wrote a tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Compile-and-Link-SFML-with-Qt-Creator) for using SFML with Qt Creator)...
This was not written by Laurent! It's a wiki, anyone can contribute. ;)

As for free IDEs on Windows, there's also Code::Blocks.

Btw I wouldn't advise to use TDM builds, because of the odd/bad quirks, instead MinGW Builds has personal builds and an installer over at the offical MinGW-w64 site. ;)
Title: Re: clion and sfml?
Post by: sharethis on September 14, 2014, 03:43:09 pm
Yes, I'm using SFML with the recently released CLion preview. You should definitely start learning CMake as CLion uses this as project files. I just posted a question regarding static linking. However, I got SFML working with CLion (http://en.sfml-dev.org/forums/index.php?topic=16332.0) sucessfully when linking dynamically. You can see the steps there.
Title: Re: AW: Re: clion and sfml?
Post by: georger on September 14, 2014, 09:51:53 pm
...(later I learned Laurent wrote a tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Compile-and-Link-SFML-with-Qt-Creator) for using SFML with Qt Creator)...
This was not written by Laurent! It's a wiki, anyone can contribute. ;)

As for free IDEs on Windows, there's also Code::Blocks.

Btw I wouldn't advise to use TDM builds, because of the odd/bad quirks, instead MinGW Builds has personal builds and an installer over at the offical MinGW-w64 site. ;)

About the wiki, my bad - I only looked at the repo owner's name, not the author of the page. Thanks for pointing it out.

I like Code::Blocks, so much that I gathered together a bunch of colour themes (http://wiki.codeblocks.org/index.php?title=Syntax_highlighting_custom_colour_themes) for it - but ran into this debugger problem (http://forums.codeblocks.org/index.php/topic,19221.0.html) last year, when I switched both my Windows PC and my compiler to 64-bit. I used Code::Blocks a lot and I intend to use it again when they fix that problem. Since then I've been using mostly VSEE 2013, and now I'm trying Qt Creator.

About TDM, I've heard about those problems, but *never ever* run into one of them myself - and I've used it a lot since Dec'13. Rock solid, not a single issue, I've been pretty happy with it. On the other hand, I once tried to install a MinGW-builds toolchain (can't recall which) and couldn't get it to work... Go figure.

I've already gone way off-topic, so let me come back to the topic and I'll wrap up: I think CLion absolutely *needs* to support Windows GCC builds based on MinGW-w64, because standard MinGW32 suffers from a number of limitations at the moment that MinGW-w64 does not; and, based on my own experience, I recommend VSEE 2013 (std::make_unique<>(), yay!) and Qt Creator with its bundled MinGW 4.8.2 toolchain (which is based on MinGW-builds, by the way).
Title: Re: clion and sfml?
Post by: eXpl0it3r on September 14, 2014, 11:25:20 pm
About TDM, I've heard about those problems, but *never ever* run into one of them myself - and I've used it a lot since Dec'13. Rock solid, not a single issue, I've been pretty happy with it. On the other hand, I once tried to install a MinGW-builds toolchain (can't recall which) and couldn't get it to work... Go figure.
As long as you only use like one or maybe two libraries, things might just work fine. If you however start to seriously build up a library "system", then the TDM build will sooner than later create issues, unless you explicitly handle all the TDM quirks, as SFML does. The main issue is, that unless a build system is laid out for the TDM compilers, it can/will generate binaries that are not the way the build system intended them to be.
As for the MinGW-builds: they've gone through some changes, but their latest installer etc. looks fine and well they are already at GCC 4.9.1.

I've already gone way off-topic, so let me come back to the topic and I'll wrap up: I think CLion absolutely *needs* to support Windows GCC builds based on MinGW-w64, because standard MinGW32 suffers from a number of limitations at the moment that MinGW-w64 does not;
I don't know if people are just too lazy or don't know the right tools, but for me it took like 30min to get CLion working with my MinGW-w64 GCC 4.9.1 build... ::)

I haven't worked much with it though, so I can't really judge it. That it uses CMake directly as project files, seems nice and it also seems to integrate better than in the Qt Creator (last I checked that one out).
But the IDE feels quite slow. Some of the changes take a long time to get "recognized" and navigating around takes also quite some time. I can only imagine how much time gets wasted, if one has to wait a second or two for every click one does. Maybe performance increases with a release, but as of now the IDE would probably prevent me more from working on code, than actually helping me much.
I don't have a project at hand to test the refactoring stuff, so that may still be great. ;)

The main argument against CLion however is, that it most likely will turn into a paying product after the EAP. If you make money writing code though, it might still be an option for you.
Title: Re: clion and sfml?
Post by: georger on September 15, 2014, 03:43:42 am
I've already gone way off-topic, so let me come back to the topic and I'll wrap up: I think CLion absolutely *needs* to support Windows GCC builds based on MinGW-w64, because standard MinGW32 suffers from a number of limitations at the moment that MinGW-w64 does not;
I don't know if people are just too lazy or don't know the right tools, but for me it took like 30min to get CLion working with my MinGW-w64 GCC 4.9.1 build... ::)

I don't know whether you are just too assumptive or don't know how to resist the urge to show off, but I'm not lazy nor ignorant. I read the documentation for CLion, I looked up the issue in the issue tracking system, and since I prefer when things just work, I accepted the fact that the product doesn't officially support a particular toolchain. Then you spend *THIRTY MINUTES* (way too much time to configure any IDE) hacking an unsupported toolchain and spout these assumptions.
Title: Re: clion and sfml?
Post by: zsbzsb on September 15, 2014, 05:55:27 am
Quote
Then you spend *THIRTY MINUTES* (way too much time to configure any IDE)

Really?? Too much time?? If you get paid full time as a programmer that is 40 hours on average a week spent typing away at code. 30 minutes is 1/80th of 1 weeks time... Seriously, if you can't be bothered to spend a few minutes setting up and IDE I don't want to see what kind of code you would write either. Heck, on complicated projects you can spend longer than that setting up your other tools and configuring stuff just to build the project right.
Title: AW: clion and sfml?
Post by: eXpl0it3r on September 15, 2014, 06:35:35 am
Well it's not supported officially, but MinGW is MinGW, they work the same way. It's just a question of figuring out what CLion is looking for to only accept the old MinGW as compiler.

As a programmer our "job"is to solve problems. Giving up on a problem just because something is not officially supported can be viewed as being a little lazy. If one does know how MinGW compiler "work", at least up to a certain point, it becomes obvious that if something supports one MinGW version, it should with a high cance also support another version.

So what does CLion look for? If one runs procmon if becomes obvious that CLion is trying to read from <MinGW dir>/include/_mingw.h. Since I had no old MinGW version anymore, I then had download and install it, to see what this "magic" header file holds. In the end the header is simply used to retrieve the MinGW version, all the rest can be deleted without issue.
With the header in place CLion now recognizes the MinGW version and finds the long existing g++.exe, gcc.exe and mingw32-make.exe.

Maybe I was a bit showing off, but mainly because it's not such a hard task if one actually tries to take on the challenge and understands their tools. ;)
Title: Re: AW: clion and sfml?
Post by: Grundkurs on September 15, 2014, 10:34:59 pm
So what does CLion look for? If one runs procmon if becomes obvious that CLion is trying to read from <MinGW dir>/include/_mingw.h. Since I had no old MinGW version anymore, I then had download and install it, to see what this "magic" header file holds. In the end the header is simply used to retrieve the MinGW version, all the rest can be deleted without issue.
With the header in place CLion now recognizes the MinGW version and finds the long existing g++.exe, gcc.exe and mingw32-make.exe.

Maybe I was a bit showing off, but mainly because it's not such a hard task if one actually tries to take on the challenge and understands their tools. ;)
Thanks for the hint, well appreciated ;-)
Title: Re: clion and sfml?
Post by: eXpl0it3r on September 16, 2014, 12:14:38 am
I'm glad it helped you! :)

I made a brief blog post (http://dev.my-gate.net/2014/09/how-to-use-mingw-w64-with-clion/) about it, since I guess it might be useful for other people out there as well.