I'm trying to compile the code found in https://www.glfw.org/documentation. This code is in "main.cpp" and I have a folder in the same directory called "dependencies" containing: "glfw3.h", "glfw3.lib" and "libglfw3.a". project directory dependencies
I go to the directory in powershell and run:
g main.cpp -ldependencies .\dependencies\libglfw3.a -lopengl32 -lgdi32
and it returns:
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldependencies: No such file or directory
collect2.exe: error: ld returned 1 exit status
What have I done wrong?
I've looked all the internet for solutions but none have worked even when I exactly do what is shown on the tutorial or solution, im quite stuck. I think its because im attempting to do this without an IDE (I used visual studio) and until recently i've only did C development with an IDE and i'm inexperienced with compiling and linking outside of IDE's.
CodePudding user response:
g main.cpp -ldependencies .\dependencies\libglfw3.a -lopengl32 -lgdi32
should be
g main.cpp -Ldependencies -lglfw3 -lopengl32 -lgdi32
-L
for a directory to search, -l
for the name of the library to link with.