ITADN

undefined reference to `gladLoadGL', ...

#525Closedgay-chicken 创建于 2025-10-23
G
gay-chickencommented
I'm trying to upgrade Glad1 to Glad2 and I'm getting "undefine reference" errors when building. ``` >gcc glad_unit.c -o glad_unit D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccrq7Vxp.o:glad_unit.c:(.text+0x27): undefined reference to `gladLoadGL' D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccrq7Vxp.o:glad_unit.c:(.text+0x2c): undefined reference to `gladInstallGLDebug' D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccrq7Vxp.o:glad_unit.c:(.text+0x31): undefined reference to `gladLoaderLoadGL' ``` here is the test code I used to find the "undefine reference" error: ``` #include <stdio.h> #include "gl.h" // we assume this is `glfwGetProcAddress` typedef void (*GLFWglproc)(void); GLFWglproc glfwGetProcAddress(const char*) { return NULL; } int main() { #ifndef GL_BOOL #error "undefine GL_BOOL!" #endif gladLoadGL(glfwGetProcAddress); gladInstallGLDebug(); gladLoaderLoadGL(); } ``` the folder structure is: ``` glad ├─ gl.h └─ glad_unit.c ``` glad2 generated options: ``` * Generator: C/C++ * Specification: gl * Extensions: 621 * * APIs: * - gl:core=4.6 * * Options: * - ALIAS = False * - DEBUG = True * - HEADER_ONLY = True * - LOADER = True * - MX = False * - ON_DEMAND = False ``` I can be sure that the header file is being imported correctly because the macro is defined correctly.
关闭于 2025-10-23 1 条评论