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

Author Topic: Cant get working SFML with clion  (Read 2607 times)

0 Members and 2 Guests are viewing this topic.

Tall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Cant get working SFML with clion
« on: January 13, 2018, 03:42:22 pm »
hi, im trying to use Clion with SFML, im using minGW compiler, im on Windows 10.

When i try to compile, i get this error: No rule to make target '01Chess'.  Stop.


Cmake file

cmake_minimum_required(VERSION 3.2)
project(01Chess)

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

set(SOURCE_FILES main.cpp)
add_executable(01Chess ${SOURCE_FILES})

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(01Chess ${SFML_LIBRARIES})
endif()



main.cpp file

#include <SFML/Graphics.hpp>
#include "config.h"

int main() {
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

        window.clear();
        window.draw(shape);
        window.display();
    }
    return 0;
}


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11028
    • View Profile
    • development blog
    • Email
Re: Cant get working SFML with clion
« Reply #1 on: January 13, 2018, 04:34:42 pm »
What if you don't use 01 at the beginning? Did CMake run successfully for Clion?

Sent from my Nexus 5X using Tapatalk

Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Cant get working SFML with clion
« Reply #2 on: January 13, 2018, 07:19:54 pm »
i have tryied to change project name, and now im getting this

CMake Error at cmake_modules/FindSFML.cmake:355 (message):
  Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
  SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY)
 

I tried a simple helloWorld program and it worked with cmake
« Last Edit: January 13, 2018, 07:28:26 pm by Tall »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11028
    • View Profile
    • development blog
    • Email
Re: Cant get working SFML with clion
« Reply #3 on: January 13, 2018, 10:14:34 pm »
Well the error tells you the issue, it can't find SFML. You can set SFML_ROOT to tell CMake where to find it.
« Last Edit: January 14, 2018, 11:44:45 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Cant get working SFML with clion
« Reply #4 on: January 14, 2018, 12:40:37 pm »
ok, i have tryied to change things in the cmakeLists file. and now the error changed.

mingw32-make.exe: *** No rule to make target 'BOX2D'.  Stop.


CMakeLists.txt

cmake_minimum_required(VERSION 3.7)
project(BOX2D)

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

set(SOURCE_FILES main.cpp)
add_executable(BOX2D ${SOURCE_FILES})

set(CMAKE_MODULE_PATH "D:/c++/Librerie/SFML-2.4.2/cmake/Modules" ${CMAKE_MODULE_PATH})

set(SFML_STATIC_LIBRARIES TRUE)
set(CMAKE_FIND_FRAMEWORK NEVER)

find_package(SFML COMPONENTS graphics window system REQUIRED)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${main.cpp} ${SFML_Libraries})