使用 g++ 链接 glfw 的问题

时间:2021-05-04 20:14:23

标签: c++ glfw

所以我正在尝试编译这个 glfw 代码:

#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>

int main()
{
    glfwInit();
    return 0;
}

我有一个如下所示的批处理脚本:

g++ -Wall -O2 -ID:\programowanie\C++\openGL\Libraries\include -c src/*.cpp
g++ -LD:\programowanie\C++\openGL\Libraries\lib -o bin\main.exe *.o -lglfw3

但它返回:

D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x10f): undefined reference to `__imp_CreateDCW'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x14e): undefined reference to `__imp_GetDeviceCaps'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1a3): undefined reference to `__imp_DeleteDC'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x2e3): undefined reference to `__imp_GetDeviceCaps'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x8bb): undefined reference to `__imp_GetDeviceCaps'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xa0b): undefined reference to `__imp_GetDeviceCaps'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xde8): undefined reference to `__imp_CreateDCW'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xdf7): undefined reference to `__imp_GetDeviceGammaRamp'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xe00): undefined reference to `__imp_DeleteDC'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xef8): undefined reference to `__imp_CreateDCW'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf07): undefined reference to `__imp_SetDeviceGammaRamp'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf10): undefined reference to `__imp_DeleteDC'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1e5): undefined reference to `__imp_CreateDIBSection'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x21f): undefined reference to `__imp_CreateBitmap'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x2c8): undefined reference to `__imp_DeleteObject'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x350): undefined reference to `__imp_DeleteObject'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x3e4): undefined reference to `__imp_CreateRectRgn'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x41b): undefined reference to `__imp_DeleteObject'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x14a): undefined reference to `__imp_SwapBuffers'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x3f6): undefined reference to `__imp_ChoosePixelFormat'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x404): undefined reference to `__imp_SetPixelFormat'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xb2f): undefined reference to `__imp_DescribePixelFormat'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x107a): undefined reference to `__imp_DescribePixelFormat'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1095): undefined reference to `__imp_SetPixelFormat'
D:\programowanie\C++\openGL\Libraries\lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1376): undefined reference to `__imp_DescribePixelFormat'
collect2.exe: error: ld returned 1 exit status

我用以下方式下载了 glfw:windows 用 mingw 预编译的二进制文件

0 个答案:

没有答案