【发布时间】:2020-10-18 12:05:00
【问题描述】:
我已经从源代码构建了 GLFW,并尝试在 Ubuntu Linux 上使用它构建应用程序。但是,g++ 总是抛出关于未定义引用的错误。我关注了许多网站和帖子,但它们并没有解决我的问题。这是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
using namespace glm;
int main() {
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window;
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental=true;
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
return 0;
}
我正在用这个命令编译这个程序:g++ glfw_prog.cpp -lGL -lglfw3 -o glfw_prog。
但是,我收到了这个很长的错误https://pastebin.com/1b8fB2h7。
如何解决这个问题?
【问题讨论】:
-
请不要使用错误消息的屏幕截图。相反,使用正确的格式(作为代码)粘贴错误消息。另请参阅How to Ask。
-
我提供的链接不是任何截图。这是一个显示错误的文本。我无法在此处粘贴它,因为它超过了字数限制。
-
哦,对不起,这不是截图。尽管如此,错误消息仍应直接粘贴到问题帖子中。如果您的日志太长,则只显示第一条错误消息,或几条第一条消息。如果您认为完整的日志也有用,您也可以提供它的链接。