3

I built GLEW (using make install) to use in a small test program I am writing (source can be found here if you need it). I ran locate libGLEW.so just to check if the GLEW libraries were properly installed, and got the following output:

/usr/lib64/libGLEW.so
/usr/lib64/libGLEW.so.2.0
/usr/lib64/libGLEW.so.2.0.0

This was completely normal. I then compiled it using the command:

g++ main.cpp -o main -lglfw -lGLEW -lGL -lX11 -lpthread -lXi -g

This also threw up no errors. However, when I tried to execute the program:

./main: error while loading shared libraries: libGLEW.so.2.0: cannot open shared object file: No such file or directory

Just for a sanity check, I ran ldd main | grep "GLEW", and sure enough:

libGLEW.so.2.0 => not found

I initially thought that this could be a problem with the linker not searching the directory containing the libraries. So I ran the command ld --verbose | grep "/usr/lib64" and there was a SEARCH_DIR containing the required directory:

...  SEARCH_DIR("=/usr/lib64"); ...

This was especially confusing. I tried compiling with the -L/usr/lib64 option, but the same error message still persisted. I checked that the symlinks to the library were correct and they were:

lrwxrwxrwx  1 root root   16 Jul 15 10:22 libGLEW.so -> libGLEW.so.2.0.0
lrwxrwxrwx  1 root root   16 Jul 15 10:38 libGLEW.so.2.0 -> libGLEW.so.2.0.0
-rw-r--r--  1 root root 707K Jul 15 10:22 libGLEW.so.2.0.0

I am not sure what exactly is causing the issue but I'm starting to believe that I didn't install the libraries correctly. I feel like the answer is right in front of my eyes but I can't find it.

Thanks in advance for any help.

2 Answers2

1

Debian and Ubuntu do not install system libraries into /usr/lib64, and the installation instructions you used are wrong for those systems. (It is not a good idea to install libraries bypassing the packaging system into /usr anyway.) /usr/local/lib is searched by default (unlike other systems), so you could move the libraries to that directory.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • I gave that a try, however the program is still not linked properly to libGLEW.so.2.0. I may try this on a different system to check if it's a problem with my computer. –  Jul 18 '17 at 00:26
  • Same as before, when I run`ldd main` it isn't linked properly to libGLEW.so.2.0 –  Jul 18 '17 at 14:40
-1

Compile with -Wl,-rpath=/usr/lib64

JRG
  • 2,065
  • 2
  • 14
  • 29
  • According to g++ neither of these are valid command line options. –  Jul 15 '17 at 21:39
  • That is a single flag: https://stackoverflow.com/questions/6562403/i-dont-understand-wl-rpath-wl – JRG Jul 16 '17 at 22:44