gpt4 book ai didi

c++ - Windows C++ 如何安装 GLFW 库?

转载 作者:行者123 更新时间:2023-11-30 04:43:28 37 4
gpt4 key购买 nike

我正在为游戏的窗口部分编写代码。代码给出错误。我认为错误的原因是缺少 GLFW 库。我使用 Notepad++ 进行编辑,使用 MinGW 进行编译。如何将库安装到我的文件夹?

错误:

NPP_SAVE: C:\Users\User\Desktop\game\src\main.cpp
CD: C:\Users\User\Desktop\game\src
Current directory: C:\Users\User\Desktop\game\src
g++ "main.cpp" -o main -march=native -O3
Process started (PID=1568) >>>
In file included from main.cpp:4:
Display.h:7:10: fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
compilation terminated.
<<< Process finished (PID=1568). (Exit code 1)
NPP_RUN: main
; executing: NPP_RUN main
- the specified file was not found
================ READY ================

最佳答案

您不需要安装库,您只需要告诉编译器在哪里可以找到您需要的头文件和库。如何执行此操作取决于您的构建环境。如果你只使用 mingw g++,你需要以下选项:

  • -I(这是一个大写的 i!)(指定包含文件的路径,在您的例子中是 glfw/include 目录的路径)
  • -L(库路径,在您的例子中是包含 glfw3.lib 的文件夹)
  • -l(这是一个小写的 L!)(要使用的库列表,在您的例子中是 glfw3,没有扩展名)

关于c++ - Windows C++ 如何安装 GLFW 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58255299/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com