马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本人在使用g++编译vscode下的 OpenGL程序 出现了以下错误 希望指点一下我自己也试着用visual studio 自带的开发者命令提示符打开vscode 可是还是出现下面的问题
这是 tasks.json 中的命令行
(源代码在最后)// 这里选的是 args 的部分 使用的是 g++ 编译器
:\Users\ADMINI~1.PC-\AppData\Local\Temp\cck9WU2t.o:main.cpp:(.text+0x110a2): undefined reference to `gladLoadGLLoader'
C:\Users\ADMINI~1.PC-\AppData\Local\Temp\cck9WU2t.o:main.cpp:(.text+0x110df): undefined reference to `glad_glViewport'
C:\Users\ADMINI~1.PC-\AppData\Local\Temp\cck9WU2t.o:main.cpp:(.text+0x1113a): undefined reference to `glad_glClearColor'
C:\Users\ADMINI~1.PC-\AppData\Local\Temp\cck9WU2t.o:main.cpp:(.text+0x11167): undefined reference to `glad_glClear'
C:\Users\ADMINI~1.PC-\AppData\Local\Temp\cck9WU2t.o:main.cpp:(.text+0x111a3): undefined reference to `glad_glViewport'
//这上面的都是 glad 库里面的函数 我还没有将 glad 库包含进来
//下面的都是 glfw 莫名奇妙的错误 我自己感觉好像有一些是 windows.h 里面的函数
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(init.c.obj):init.c:(.text+0xb9): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(init.c.obj):init.c:(.text+0xda): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(init.c.obj):init.c:(.text+0x11c): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(input.c.obj):input.c:(.text+0xe46): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(input.c.obj):input.c:(.text+0xe51): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(input.c.obj):input.c:(.text+0xe5c): more undefined references to `__mingw_free' follow
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(input.c.obj):input.c:(.text+0x220c): undefined reference to `__mingw_realloc'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(input.c.obj):input.c:(.text+0x1606): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0xc2): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0xd0): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0xde): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x114): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x122): more undefined references to `__mingw_free' follow
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x2bd): undefined reference to `__mingw_realloc'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x392): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3a0): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3ae): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3e4): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3f2): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(monitor.c.obj):monitor.c:(.text+0x400): more undefined references to `__mingw_free' follow
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x113): undefined reference to `CreateDCW@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x16b): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1c6): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1fa): undefined reference to `DeleteDC@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x21f): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x35c): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x373): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x623): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x98d): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x9a4): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xb1d): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xb34): undefined reference to `GetDeviceCaps@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xdd6): undefined reference to `__mingw_realloc'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf78): undefined reference to `CreateDCW@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf8d): undefined reference to `GetDeviceGammaRamp@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf98): undefined reference to `DeleteDC@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x10fd): undefined reference to `CreateDCW@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x110e): undefined reference to `SetDeviceGammaRamp@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1119): undefined reference to `DeleteDC@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x25f): undefined reference to `CreateDIBSection@24'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x2ac): undefined reference to `CreateBitmap@20'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x34a): undefined reference to `DeleteObject@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x355): undefined reference to `DeleteObject@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x3fa): undefined reference to `DeleteObject@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x4c3): undefined reference to `CreateRectRgn@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x502): undefined reference to `DeleteObject@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xe51): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xe89): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xe9b): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1f88): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x2383): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x4c1c): more undefined references to `__mingw_free' follow
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x14a): undefined reference to `SwapBuffers@4'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x424): undefined reference to `ChoosePixelFormat@8'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x437): undefined reference to `SetPixelFormat@12'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xc30): undefined reference to `DescribePixelFormat@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xdf4): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xe25): undefined reference to `DescribePixelFormat@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xe4f): undefined reference to `SetPixelFormat@12'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x147c): undefined reference to `DescribePixelFormat@16'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x153e): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1594): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(egl_context.c.obj):egl_context.c:(.text+0xb9e): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(egl_context.c.obj):egl_context.c:(.text+0xba6): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(egl_context.c.obj):egl_context.c:(.text+0x11f8): undefined reference to `__mingw_free'
C:\Users\Administrator.PC-20191006TRUC\source\repos\OpenGL\.vscode\OpenGL\glfw-3.3.5.bin.WIN32\lib-mingw\libglfw3.a(egl_context.c.obj):egl_context.c:(.text+0x1204): more undefined references to `__mingw_free' follow
collect2.exe: error: ld returned 1 exit status
这里是源代码 没有渲染什么图像 仅仅只是创建了个OpenGL的窗口
#include <glad\glad.h>
#include <GLFW\glfw3.h>
#include <iostream>
#include <Shader\Shader.h>
#include <glm\glm.hpp> //OpenGL的数学库
#include <glm\gtc\type_ptr.hpp>
#include <glm\gtc\matrix_transform.hpp>
#define STB_IMAGE_IMPLEMENTATION
#include <stb\stb_image.h> //图片解析库
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow* window);
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello, OpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window))
{
processInput(window);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
void processInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
{
glfwSetWindowShouldClose(window, true);
}
}
|