Error Loading Shared Library (glew)
Asked Answered
P

2

7

I compiled the library GLEW. It seemed to work fine, here is the output of make install:

install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
        -e "s|@prefix@|/usr|g" \
        -e "s|@libdir@|/usr/lib64|g" \
        -e "s|@exec_prefix@|/usr/bin|g" \
        -e "s|@includedir@|/usr/include/GL|g" \
        -e "s|@version@|1.11.0|g" \
        -e "s|@cflags@||g" \
        -e "s|@libname@|GLEW|g" \
        -e "s|@requireslib@|glu|g" \
        < glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib64"
install -m 0644 lib/libGLEW.so.1.11.0 "/usr/lib64/"
ln -sf libGLEW.so.1.11.0 "/usr/lib64/libGLEW.so.1.11"
ln -sf libGLEW.so.1.11.0 "/usr/lib64/libGLEW.so"
install -m 0644 lib/libGLEW.a "/usr/lib64/"
install -d -m 0755 "/usr/lib64"
install -d -m 0755 "/usr/lib64/pkgconfig"
install -m 0644 glew.pc "/usr/lib64/pkgconfig/"

Now I wanted to use it on a KDevelop project. I created my CMakeLists.txt and linked the library there using find_package:

cmake_minimum_required( VERSION 2.6 )

project(openglengine)

include_directories(headers)

set(SOURCE_FILES src/main.cpp)

set(CMAKE_CXX_FLAGS "--pedantic-errors -Wall -std=gnu++11")
add_executable(openglengine ${SOURCE_FILES} ${HEADER_FILES})

find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(openglengine ${GLFW_STATIC_LIBRARIES})

find_package(GLEW)
if (GLEW_FOUND)
    include_directories(${GLEW_INCLUDE_DIRS})
    target_link_libraries (openglengine ${GLEW_LIBRARIES})
endif (GLEW_FOUND)

install(TARGETS openglengine RUNTIME DESTINATION ~/projects/OpenGLEngine/bin)

I get no build errors. When I try to run the program here is the output:

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

Any help will be appreciated.

EDIT:

Using the command locate libGLEW I get this output:

/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.6
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.10
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.10.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.6
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.6.0
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.a
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so.1.11
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so.1.11.0
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.a
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so.1.11
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so.1.11.0
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.a
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so.1.11
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so.1.11.0
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.a
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so.1.11
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so.1.11.0
/usr/lib64/libGLEW.a
/usr/lib64/libGLEW.so  
/usr/lib64/libGLEW.so.1.11
/usr/lib64/libGLEW.so.1.11.0

Which show that I have the library. Does that mean that the command find_package may be not working? Which is strange because I get no link errors.

Pizor answered 14/10, 2014 at 23:58 Comment(2)
Did you add /usr/local/lib into /etc/ld.so.conf and did you run ldconfig? Or link your program with some -Wl,-rpathMockingbird
@BasileStarynkevitch No, I didnt do any of that. Am I supposed to? All that I did was the CMakeLists that I posted above and the glew compilation, wich was entering the glew paste and doing make and make installPizor
P
15

So, I managed to make it work by creating a symbolic link in /usr/lib/ for the library that was in /usr/lib64.

sudo ln -s /usr/lib64/libGLEW.so.1.11 /usr/lib/libGLEW.so.1.11

Now it works fine. Since I am no expert on linux I don't know if that will bring me problems in the future.

Pizor answered 15/10, 2014 at 20:45 Comment(5)
I dont have this library installed, can anyone have instructions to install that?Mallarme
Worked for me!!Civilly
@AnuragDaware it can be installed by following this guide glew.sourceforge.net/install.htmlCivilly
@ShubhamDharma - Thanks Ill give it a try.Mallarme
I think the error occurs because GLEW_STATIC was not defined. [#49741822Coaxial
M
1

I don't know if the answer by @Ihahn will have any issues but, if the some program is not finding your shared libraries, then first find the folder that your library was installed and is not in your shared library folder and then run sudo ldconfig <location_where_your_library_or_program_was_installed>. Sometimes this happens when you're installing/building programs via make install.Reference here..

Marcellmarcella answered 29/11, 2019 at 4:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.