Error Loading Shared Library (glew)

13,039

Solution 1

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.

Solution 2

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..

Share:
13,039
lhahn
Author by

lhahn

Graduate Student in Computer Science

Updated on June 17, 2022

Comments

  • lhahn
    lhahn almost 2 years

    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.