Hello, I am trying to build a super simple test program with GLFW on window 10 with gcc and MinGW using the static libraries, but I keep getting undefined referenced errors.
test.c:
#include <glfw3.h>
int main() {
glfwInit();
glfwTerminate();
return 0;
}
And here is what I want to do:
gcc -c test.c -Iinclude
gcc test.o -lglfw3 -lgdi32 -o test.exe
And here is the error is gives me:
test.o:test.c:(.text+0xc): undefined reference to `glfwInit'
test.o:test.c:(.text+0x11): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
List of things I have tried:
- I have tried both the 32bit and 64bit glfw3 static libraries.
- I have tried also linking other libraries references on the documentation I specified earlier such as kernel32 and user32 with no change to the error.
- I have tried changing the order in which I link libraries.
I am slightly confused with this error, are the definitions for glfwInit
and glfwTerminate
not somewhere in the libglfw3.a
? Surely they are? But, if so why does the linker throw undefined reference error?