为Clion配置SFML(Windows) [英] configure SFML for clion (windows)

查看:550
本文介绍了为Clion配置SFML(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows计算机上为学校项目设置工作环境。我们将使用c ++和CLion制作基本游戏。要制作游戏,我需要使用SFML库。我遵循了一些教程,但无论如何我似乎都无法使它正常工作。

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.

我有:


  • 已下载CLion并使用MinGW对其进行配置

  • 下载SFML并复制其 findSFML.cmake。文件到我称为cmake_modules的项目中的新目录中。

  • 编辑了我的CMakeLists.txt文件,使其看起来像这样:


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)

所以找不到SFML?但不应使用 findSFML.cmake解决这个?感谢您提供任何帮助...谢谢! :D

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

推荐答案

我相信您错过了 link_directories()调用。您可以像这样使用它:

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.

这篇关于为Clion配置SFML(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆