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

Author Topic: I Can't make SFML works with clion and mingw  (Read 3017 times)

0 Members and 1 Guest are viewing this topic.

SushiKru

  • Newbie
  • *
  • Posts: 5
    • View Profile
I Can't make SFML works with clion and mingw
« on: October 14, 2016, 05:02:53 am »
Hello

So this is what i did:
from the SFML website download page, I:
- Downloaded the SFML library: SFML 2.4.0 built with GCC 6.1.0 MinGW (SEH) - 64-bit
- Downloaded MinGW Builds 6.1.0 (64-bit)  (and use it as the toolchain in CLion)

I put them both in a folder, this folder also contains a folder name Project which contains my sources and CLion settings
This is my main.cpp:
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;

int main(int argc, char* argv[]) {
    cout << "test" << endl;

    sf::Window window(sf::VideoMode(800, 600), "myproject");

    while (window.isOpen()) {
        sf::Event Event;
        while (window.pollEvent(Event)) {
            if (Event.type == sf::Event::Closed)
                window.close();
        }
        window.display();
    }
}

This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.6)

set(PROJECT_NAME myproject)
project(${PROJECT_NAME})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)

#sfml
set(SFML_DIR "${PROJECT_SOURCE_DIR}/../SFML-2.4.0")
set(SFML_ROOT ${SFML_DIR})
set(CMAKE_MODULE_PATH "${SFML_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)

include_directories(${SFML_INCLUDE_DIR})
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES})
 

it compiles without error:
"C:\Program Files (x86)\JetBrains\CLion 2016.2.2\bin\cmake\bin\cmake.exe" --build C:\Users\SushiSalami\.CLion2016.2\system\cmake\generated\Project-edb1033a\edb1033a\Debug0 --target myproject -- -j 4
-- Found SFML 2.4.0 in D:/Development/C-C++/myproject/SFML-2.4.0/include
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/SushiSalami/.CLion2016.2/system/cmake/generated/Project-edb1033a/edb1033a/Debug0
[ 50%] Building CXX object CMakeFiles/myproject.dir/main.cpp.obj
[100%] Linking CXX executable myproject.exe
[100%] Built target myproject
 

but when i run, the application crash directly without any error except the exit code that is different from 0:
Process finished with exit code -1073741515 (0xC0000135)
"

Ofc i googled this but i can't find anything revelant  >:(

Thank you :)
« Last Edit: October 14, 2016, 05:10:58 am by SushiKru »

SushiKru

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: I Can't make SFML works with clion and mingw
« Reply #1 on: October 14, 2016, 05:32:18 am »
I think it's a dll problem, i found few topics talking about this, like this one:
http://stackoverflow.com/questions/31066330/mingw-sfml-giving-error-code

but i still can't get it works, i copied all SFML/bin dlls in my folder containing the executable. I also added mingw bin folder to PATH variable but i still get the same problem, i don't really know what to do

SushiKru

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: I Can't make SFML works with clion and mingw
« Reply #2 on: October 14, 2016, 05:38:19 am »
Ok nevermind, i am really stupid, the problem was missing dlls (sfml dlls) but i was trying the wrong executable ... for some reasons i had 2 folders, Debug and Debug0 (probably because i changed the target name in CMakeLists).

 

anything