Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: clion and sfml?  (Read 27103 times)

0 Members and 3 Guests are viewing this topic.

firstep

  • Newbie
  • *
  • Posts: 14
    • View Profile
clion and sfml?
« 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

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: clion and sfml?
« Reply #1 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

firstep

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: clion and sfml?
« Reply #2 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?

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: clion and sfml?
« Reply #3 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)
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!
« Last Edit: September 10, 2014, 10:29:20 am by Strelok »

jokoon

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: clion and sfml?
« Reply #4 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++

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: Re: clion and sfml?
« Reply #5 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.

firstep

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: clion and sfml?
« Reply #6 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?

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: Re: clion and sfml?
« Reply #7 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.

georger

  • Guest
Re: clion and sfml?
« Reply #8 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, 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 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.
« Last Edit: September 14, 2014, 09:55:01 pm by georger »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Re: clion and sfml?
« Reply #9 on: September 14, 2014, 03:27:28 pm »
...(later I learned Laurent wrote a tutorial 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sharethis

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: clion and sfml?
« Reply #10 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 sucessfully when linking dynamically. You can see the steps there.

georger

  • Guest
Re: AW: Re: clion and sfml?
« Reply #11 on: September 14, 2014, 09:51:53 pm »
...(later I learned Laurent wrote a tutorial 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 for it - but ran into this debugger problem 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).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: clion and sfml?
« Reply #12 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

georger

  • Guest
Re: clion and sfml?
« Reply #13 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.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: clion and sfml?
« Reply #14 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.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

 

anything