【发布时间】:2021-03-03 14:53:18
【问题描述】:
我在 Linux 中使用 glfw 制作了一个简单的程序。我现在想在 Windows 中构建它。
当我在 Linux 中安装 glfw 时,我做了以下步骤。
- 安装 CMake。
- 下载 glfw 源代码。
- 在源代码文件夹中创建一个构建文件夹。
- 在构建文件夹中执行“cmake ../”
- 做“做”
- 执行“make install”
然后在 CMakeLists.txt 文件中:
find_package( glfw3 3.3 REQUIRED )
add_executable(main main.cpp)
target_link_libraries(main glfw)
在源代码中:
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
//use glfw
所以我想在 Windows Visual Studio 中做同样的事情。
我做了以下步骤。
- 安装 CMake
- 下载 glfw 源文件。
- 在源代码文件夹中创建构建文件夹。
- 在构建文件夹中执行“cmake ../”
- 转到 build 文件夹,使用管理员权限在 Visual Studio 中打开 GLFW 项目。
- 在 Visual Studio 中构建 ALL_BUILD。
结果,我得到了 C:\Program Files (x86)\GLFW 文件夹。有包含、库、配置文件。
然后我创建了一个新的 CMake 项目。
CMake 文件:
cmake_minimum_required (VERSION 3.8)
set (CMAKE_PREFIX_PATH "C:\Program Files (x86)\GLFW\lib\cmake\glfw3")
find_package( glfw3 3.3 REQUIRED )
include_directories( "C:\Program Files (x86)\GLFW" )
project ("glfw_test")
add_executable (glfw_test "glfw_test.cpp" "glfw_test.h")
错误信息说:
CMake Error at C:\Users\home\source\repos\glfw_test\CMakeLists.txt:3 (set):
Syntax error in CMake code at
C:/Users/home/source/repos/glfw_test/CMakeLists.txt:3
when parsing string
C:\Program Files (x86)\GLFW\lib\cmake\glfw3
Invalid character escape '\P'. glfw_test C:\Users\home\source\repos\glfw_test\CMakeLists.txt 3
问题。
- 为什么include、lib文件直接安装在程序文件中(x86)?
- 如何在 Windows 中进行“make install”?
【问题讨论】:
-
您必须使用 / 作为路径分隔符而不是 \ 或像在 c++ 中那样转义路径
标签: c++ visual-studio installation cmake glfw