0

I'm trying to compile a program with GLAD and SDL2 using scons (though scons isn't really relevant since g++ is the issue)

scons runs the following command to compile part of the program:

g++ -o out/cpptest bin/src/MainTest.o bin/src/main.o -L/usr/local/lib -Lbin/lib -ldl -lm -lGL -lGLU -lX11 -lpthread -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lglad -lSDL2 -pthread

g++ returns the following error message:

/usr/bin/ld: bin/lib/libglad.a(glad.c.o): undefined reference to symbol 
'dlclose@@GLIBC_2
.2.5'
 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libdl.so: error 
 adding symbols: DSO missing from command line
 collect2: error: ld returned 1 exit status

Some advice would be much apreciated.

Also note the following flags ARE present:

    -ldl -lm -lpthread -pthread
0

You simply need to add the flags "-Wl and --start-group"

for scons add LINKFLAGS=['-Wl,--start-group'].

Reference: https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.