我正在编码游戏的窗口部分。代码给出错误。我认为错误的原因是缺少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 ================
Run Code Online (Sandbox Code Playgroud)
您无需安装库,只需告诉编译器在哪里可以找到所需的标头和库。如何执行此操作取决于您的构建环境。如果您仅使用 mingw g++,则需要以下选项:
-I(这是一个大写的 i!)(指定包含文件的路径,在您的情况下是 glfw/include 目录的路径)-L(库的路径,在您的情况下是包含 glfw3.lib 的文件夹)-l(这是一个小写的 L!)(要使用的库列表,在您的情况下为 glfw3,不带扩展名)