0

So I am trying to compile a basic application and when i try and compile it, it throws an error:

$ g++ -g -Iinclude -ldl -lX11 -lstdc++ src/*.cpp src/*.c `pkg-config --cflags --libs glfw3 glib-2.0`
/usr/bin/ld: warning: librt.so.1, needed by /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libglfw.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /tmp/ccJamhTZ.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

main.cpp:

#include <glad/glad.h>
#include <GLFW/glfw3.h>

int main(int argc, char** argv) {
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    return 0;
}

What causes this and how do I fix it?

Slendi
  • 157
  • 1
  • 13

1 Answers1

0

Are you sure you've downloaded the glfw and glad developer packages for Ubuntu? I am on Fedora and can't really say I've had problem with yours snippet. Here: https://ubuntu.pkgs.org/18.04/ubuntu-universe-amd64/libglfw3-dev_3.2.1-1_amd64.deb.html is apparently Ubuntu's dev package, but I suggest to see how to install the dev package for your distribution and respective version. [edit] I've compiled your snippet with: g++ -o test main.cpp -I/usr/include/GLFW -lglfw but removed the #include<glad/glad.h> since I don't have that library.

Ilian Zapryanov
  • 1,132
  • 2
  • 16
  • 28