Bonbin Bonbin - 9 days ago 16
C++ Question

configure SFML for clion (windows)

i am setting up a work environment for a school project on my windows computer. We are going to make a basic game using c++ and CLion. To make a game i need to use the SFML library. I have followed a few tutorials but i cant seem to get it to work anyway.

I have:


  • Downloaded CLion and configured it with MinGW

  • Downloaded SFML and copied its "findSFML.cmake" file to a new directory in my project that i call cmake_modules.

  • Edited my CMakeLists.txt file so it looks like this:




cmake_minimum_required(VERSION 3.6)
project(testet)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)

add_executable(testet ${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(testet ${SFML_LIBRARIES})
endif()



These are the three steps that i see on every tutorial / answer. But I get the following error anyway:

"C:\Program Files (x86)\JetBrains\CLion 2016.3\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\Benjamin\ClionProjects\testet
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)
Call Stack (most recent call first):
CMakeLists.txt:10 (find_package)


So it cant find the SFML? But should'nt the "findSFML.cmake" solve this? Any help is appretiated... Thanks! :D

Answer

I believe you are missing the link_directories() call. You can use it like this:

link_directories("C:/Path_To_Library")

This should help solve your issue.

Comments