Answer the question
In order to leave comments, you need to log in
Why is there an undefined reference here?
Hello!
I'm trying to compile the source file, the linker stumbles on this line:
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/glext.h>
#include <GLFW/glfw3.h>
...
glGenBuffers(0, 0);
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w
64-mingw32/lib/../lib/glew32s.lib(tmp/glew_static/Release/Win32/glew.obj):(.text
$mn+0x7): undefined reference to `[email protected]'
Answer the question
In order to leave comments, you need to log in
Please tell me why
a b c
symbols that the library needs b
will only be looked for in the library c
, not in the a
. If there are no cyclic dependencies between libraries (i.e., there is no one that a
defines the symbol needed b
, but b
defines the symbol needed a
), then they can be ordered so that the linking will be successful (see topological sorting ). If there are cyclic dependencies, or it’s too lazy to sort, you can list the necessary libraries several times or take them into a group:g++ main.cpp -Wl,--start-group -lglfw3 -lgdi32 -lopengl32 -lglew32s -Wl,--end-group
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question