我正在使用 Linux 操作系统和 Eclipse。由于某种原因,尽管 glfw3.h 已正确包含,但 eclipse 无法识别某些 GLFW 命令。我无法使用 GLFWwindow、glfwCreateWindow 和 glfwDestoyWindow。有谁知道为什么吗?
编辑
具体来说,我的 IDE 会在这些方法下划线,就好像它们未定义一样。
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
using namespace std;
int main() {
if (!glfwInit()){
return 0;
}
GLFWwindow* window = glfwCreateWindow(680, 480, "test", NULL, NULL);
cin.get();
if (window){
glfwDestroyWindow(window);
}
glfwTerminate();
return 0;
}
最佳答案
如果我没记错的话,C/C++模式下的Eclipse编辑器使用编译器来生成其符号数据库,因此除非您构建编辑器,否则将无法识别新符号。
因此,解决方案是实际构建您的项目,即使编辑器告诉您存在错误。
关于c++ - 为什么我不能使用一些 GLFW 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24684335/