Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: SFML reference error (CMake, Clion, Windows and MinGW)  (Lu 4383 fois)

0 Membres et 1 Invité sur ce sujet

seluj78

  • Newbie
  • *
  • Messages: 2
    • Voir le profil
    • E-mail
SFML reference error (CMake, Clion, Windows and MinGW)
« le: Avril 22, 2017, 01:13:12 pm »
I'm just recently came to know the existence of SFML and I wanted to try it out !
So I followed the instructions from the SFML Github Wiki using Cmake with Clion on Windows

Here's where I installed SFML : `C:\SFML`

Here's the layout of my Clion project folder : http://prntscr.com/ezgo1n

Here's the content of my `main.cpp`:

(click to show/hide)
Here's the content of the `config.h.in` file:
(click to show/hide)
Here's the content of my `CMakeLists.txt`: https://pastebin.com/2QQCycEv

And finally here's the error I got :
(click to show/hide)

And I can't seem to figure it out... I've looked all over stackoverflow, the forums, nothing fixed it

Any clue ?

  [1]: https://github.com/SFML/SFML/wiki/Tutorial%3A-Build-your-SFML-project-with-CMake
« Modifié: Avril 22, 2017, 01:18:55 pm par seluj78 »

jantzen

  • Newbie
  • *
  • Messages: 4
    • Voir le profil
Re: SFML reference error (CMake, Clion, Windows and MinGW)
« Réponse #1 le: Avril 22, 2017, 04:16:43 pm »
I'm not an expert in any of this, but I got an example working.

Using:
CLion 2016.3.2, with included cmake
mingw64
SFML 2.4 for mingw64, installed to C:/SFML


CMakeLists.txt
https://pastebin.com/PxhBfWmc

I had to add line 16 and change link 22 from TARGET to my project name.

Looking at your project setup, it looks like the SFML dll files are in the root of your project directory.  The dlls should be in the cmake-build-debug directory where the executable (Adventure.exe) is placed after building the project.

main.cpp
#include "config.h"
#include <iostream>
#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }

    return 0;
}
 

« Modifié: Avril 22, 2017, 04:18:51 pm par jantzen »

seluj78

  • Newbie
  • *
  • Messages: 2
    • Voir le profil
    • E-mail
Re: SFML reference error (CMake, Clion, Windows and MinGW)
« Réponse #2 le: Avril 26, 2017, 02:17:00 pm »
Alright i definitively ain't geting the errors anymore, but the errors aren't here anymore...

Clion&CMake compile perfectly, tho nowm It doesnt launch when I hit the run button. Here's the output :

C:\Users\user\Documents\Projects\Adventures\cmake-build-debug\Adventures.exe

Process finished with exit code -1073741511 (0xC0000139)


it launches then stops... I've added a define for SFML_STATIC but didn't work and i've added the .dlls everywhere in the project and still ain't good ...


(http://stackoverflow.com/questions/43634181/error-code-1073741511-0xc0000139-when-launching-a-program-made-with-sfml-in-c)
« Modifié: Avril 26, 2017, 02:26:46 pm par seluj78 »

jantzen

  • Newbie
  • *
  • Messages: 4
    • Voir le profil
Re: SFML reference error (CMake, Clion, Windows and MinGW)
« Réponse #3 le: Avril 27, 2017, 12:44:40 am »
I'm confused.  What does your main.cpp look like?  Is it the same as above?

In a stack overflow comment you stated the program exits with code 0.  If your main.cpp is the same as above this is good.  You need to change your main.cpp to look like my example.  You don't have a loop to display the window, your code only declares a window object, it doesn't use it.

Without an event loop it will just exit with code 0 and maybe flash a console window.