[英]problems with linking glfw using g++
so i'm trying to compile this glfw code:所以我正在尝试编译这个 glfw 代码:
#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
return 0;
}
i have a batch script that looks like this:我有一个看起来像这样的批处理脚本:
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
but it returns:但它返回:
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
i downloaded glfw with: windows pre-commpiled binaries with mingw我用 mingw 下载了 glfw:windows 预编译的二进制文件
I think its too late but still here's the solution:我认为为时已晚,但仍然是解决方案:
just replace -lglfw3
at the end with -lglfw3dll
and add the glfw3.dll file to your output folder which is the "bin" folder this should do只需将最后的
-lglfw3dll
-lglfw3
glfw3.dll 文件添加到您的 output 文件夹,这是应该做的“bin”文件夹
I'm not really sure why replacing this fixes the issue cause i dont really know about glfw but just experimented with it one我不太确定为什么替换它可以解决问题,因为我不太了解 glfw,但只是尝试了一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.