【发布时间】:2021-09-29 22:09:11
【问题描述】:
首先,我从他们的网站下载了适用于 Windows 的 GLFW 32 位二进制文件。以下是本次下载的内容:
然后我将“include”和“lib-vc2019”文件复制到我的 Clion 项目文件夹“OpenGL”下名为“Dependencies”的文件夹中:
按照https://www.glfw.org/docs/3.3/build_guide.html#build_link_cmake_package 的“使用 CMake 并安装 GLFW 二进制文件”中的说明进行操作
在我的 CMakeLists.txt 文件中,我有以下内容:
cmake_minimum_required(VERSION 3.19)
project(OpenGL)
set(CMAKE_CXX_STANDARD 20)
add_executable(OpenGL Main.cpp)
include_directories(Dependencies)
find_package(glfw3 3.3 REQUIRED)
target_link_libraries(OpenGL glfw)
当我尝试构建时,我收到以下错误:
CMake Error at CMakeLists.txt:10 (find_package):
By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glfw3", but
CMake did not find one.
Could not find a package configuration file provided by "glfw3" (requested
version 3.3) with any of the following names:
glfw3Config.cmake
glfw3-config.cmake
Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set
"glfw3_DIR" to a directory containing one of the above files. If "glfw3"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "C:/Users/moehe/Desktop/CS/CPP/OpenGL/cmake-build-debug/CMakeFiles/CMakeOutput.log".
mingw32-make.exe: *** [Makefile:194: cmake_check_build_system] Error 1
在这上面花了很多时间,很困惑。如果有人能提供一步一步的指导来完成这项工作,将不胜感激。
【问题讨论】:
-
正如您所注意到的,
find_package只是加载其他一些定义目标并配置它们的.cmake文件。将此文件放入您的项目中是您的职责。从字面上搜索glfw3Config.cmake开始,也许有人在他们的仓库中有一个 -
与其浪费更多的时间,不如使用Glitter,开心点。
-
错误消息告诉您确切的操作。这些 *config.cmake 文件是否存在?
-
如果您安装了 msys2 二进制文件,它们将存在:https://packages.msys2.org/package/mingw-w64-x86_64-glfw
-
我需要安装mingw-32之类的吗?
标签: c++ opengl cmake clion glfw