I am trying to compile a minimal GLFW3 program:
#include <GLFW/glfw3.h>
int main()
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
return 0;
}
However, I am getting the following error:
PS C:\GitHub\test> g++ -Wall -I GLFW/include -lglfw3 test.cpp -o test.exe
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglfw3: No such file or directory
collect2.exe: error: ld returned 1 exit status
PS C:\GitHub\test> g++ -Wall -I GLFW/include -L GLFW/lib64 -lglfw3 test.cpp -o test.exe
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0xe): undefined reference to `glfwInit'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x43): undefined reference to `glfwCreateWindow'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x53): undefined reference to `glfwTerminate'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x66): undefined reference to `glfwMakeContextCurrent'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x74): undefined reference to `glfwSwapBuffers'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x79): undefined reference to `glfwPollEvents'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x85): undefined reference to `glfwWindowShouldClose'
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\emili\AppData\Local\Temp\ccg370QG.o:test.cpp:(.text+0x93): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
I am on Windows 10 and have downloaded the 64-bit Windows version of GLFW3. If I try linking with the 32 bit version I get:
PS C:\GitHub\test> g++ -Wall -I GLFW/include -L GLFW/lib32 -lglfw3 test.cpp -o test.exe
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible GLFW/lib32/libglfw3.a when searching for -lglfw3
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible GLFW/lib32\libglfw3.a when searching for -lglfw3
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible GLFW/lib32/libglfw3.a when searching for -lglfw3
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglfw3: No such file or directory
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible GLFW/lib32/libglfw3.a when searching for -lglfw3
collect2.exe: error: ld returned 1 exit status
This is expected.