【发布时间】:2018-09-27 15:16:14
【问题描述】:
所以我想在学习 GLFW 的过程中使用 Atom 作为我的 IDE。这是我的代码
#include <GLFW\glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.0f, 0.5f);
glVertex2f(0.5f, -0.5f);
glEnd();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
所以我已经尝试搜索与我类似的问题,但幸运的是,这些问题的答案没有奏效。我已经将 GLFW 的 lib 文件添加到 MinGW lib 文件夹中,但它没有工作,这是我得到的错误。我知道我收到此错误是因为 gpp 编译器找不到 GLFW 库文件。
谢谢你的回答:D
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x17): undefined reference to `glfwInit'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x56): undefined reference to `glfwCreateWindow'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x64): undefined reference to `glfwTerminate'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x79): undefined reference to `glfwMakeContextCurrent'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x84): undefined reference to `glfwWindowShouldClose'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x9d): undefined reference to `_imp__glClear@4'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0xae): undefined reference to `_imp__glBegin@4'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0xcb): undefined reference to `_imp__glVertex2f@8'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0xe4): undefined reference to `_imp__glVertex2f@8'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x101): undefined reference to `_imp__glVertex2f@8'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x10b): undefined reference to `_imp__glEnd@0'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x118): undefined reference to `glfwSwapBuffers'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x11d): undefined reference to `glfwPollEvents'
C:\Users\Asus\AppData\Local\Temp\cc4lMOFw.o:main.cpp:(.text+0x127): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
【问题讨论】:
标签: c++ mingw atom-editor glfw