MUSTDOS
November 28, 2024, 9:23am
1
from: learnopengl Getting-started Creating-a-window tutorial
I tried compiling this part and was good; linking however was kinda of a nonsense in the debug window
DEBUG
11:11:30 **** Incremental Build of configuration Debug for project OpenGLHello ****
make all
Building target: OpenGLHello
Invoking: GCC C++ Linker
g++ -L/usr/lib/x86_64-linux-gnu/ -L"/home/mustdos/eclipse-workspace/OpenGLHello/include" -o “OpenGLHello” ./src/glad.o ./src/hello.o -lGL -lpthread -lXrandr -lXi -ldl -lX11
/usr/bin/ld: ./src/hello.o: in function `main’:
/home/mustdos/eclipse-workspace/OpenGLHello/Debug/…/src/hello.cpp:7: undefined reference to `glfwInit’
/usr/bin/ld: /home/mustdos/eclipse-workspace/OpenGLHello/Debug/…/src/hello.cpp:8: undefined reference to `glfwWindowHint’
/usr/bin/ld: /home/mustdos/eclipse-workspace/OpenGLHello/Debug/…/src/hello.cpp:9: undefined reference to `glfwWindowHint’
/usr/bin/ld: /home/mustdos/eclipse-workspace/OpenGLHello/Debug/…/src/hello.cpp:10: undefined reference to `glfwWindowHint’
collect2: error: ld returned 1 exit status
make: *** [makefile:67: OpenGLHello] Error 1
“make all” terminated with exit code 2. Build might be incomplete.
11:11:30 Build Failed. 5 errors, 0 warnings. (took 208ms)
END
I checked inside the glfw3.h and there was the glfwInit() and the rest.
You need to add glfw
to the list of libraries.
MUSTDOS
November 28, 2024, 12:55pm
3
I tried both glfw and glfw3 and I got undefined tags
/usr/bin/ld: cannot find -lglfw3
and for glfw
/usr/bin/ld: cannot find -lglfw
MUSTDOS
November 28, 2024, 1:19pm
4
Is there’s any odd reason?
Ex: naming under AntiX OS?
I don’t see a file or symlink named libglfw.so
(without any version suffix), which is what the linker needs (the versioned name is used by the run-time loader). Some distributions put those in the -devel package; but headers also go in that package, so if you have the headers you ought to have the unversioned symlink.
MUSTDOS
November 28, 2024, 1:36pm
6
From what I understand, you suggest to dig into the -devel package or cmake it if all fails.
MUSTDOS
November 28, 2024, 1:51pm
7
Odd, installing the -libglfw3-dev package had the required file; all solved
MUSTDOS
November 28, 2024, 1:53pm
8
Odd, installing libglfw3-dev helped
I tried adding the library path to include/glfw before installing the -dev package but it failed to see the header…
MUSTDOS
November 28, 2024, 2:03pm
9
I cleaned the project and now this works too
MUSTDOS
November 28, 2024, 2:06pm
10
NVM, eclipse saved the header locations…
MUSTDOS
November 28, 2024, 8:57pm
11
Turns out I can use #include “…” instead of #include <…> to use the headers relative to my project than the system.