首页 > 解决方案 > Windows C++ How to install GLFW library?

问题描述

I am coding window part of my game. Code gives error. I think the reason of the error is the lack of GLFW library. I am using Notepad++ for editing and MinGW for compiling. How can I install a library to my folder?

Error:

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 ================

标签: c++

解决方案


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

  • -I(这是一个大写的 i!)(指定包含文件的路径,在你的情况下是 glfw/include 目录的路径)
  • -L(库的路径,在您的情况下指向包含 glfw3.lib 的文件夹)
  • -l(这是一个小写的 L!)(要使用的库列表,在您的情况下为 glfw3,不带扩展名)

推荐阅读