Linking GLFW as shared object


I really enjoy GLFW’s interface which is why I use it in every project where I have to deal with windows.

Now I wanted to try something new: In my earlier projects I compiled GLFW along with my source code. To not have to deal with many files, I compiled GLFW as shared library (.so) and put it in a folder called /lib. My executable ends up in the folder /bin, where a soft link referres to /lib. As a result, the directory tree looks like this:

|- /bin
|  |- /lib (link)
|  |  |- (link)
|  |
|  |- executable
|- /lib
|  |-
|- /include (...)  //GLFW includes
|- /src
  |- (...)

Before compiling GLFW I set BUILD_SHARED_LIBS to ON. Usage is as follows:

#include <iostream>
#define GLFW_DLL
#include <GLFW/glfw3.h>

int main(){

    std::cout << "test1" << std::endl;

    int a = glfwInit();
    std::cout  << "test2" << std::endl;


In eclipse I set gcc’s -l flag to glfw and -L flag to lib/. I even set the LD_LIBRARY_PATH variable to /lib and it compiles without any issues.
However, all I get is a nice line of linker output (at runtime):

/bin/Editor: error while loading shared libraries: cannot open shared object file: No such file or directory

I couldn’t find any solution online, so that’s why I ask here. Did I made a mistake when compiling the library?
I am really desperate because of this nasty linker error.
Thank you very much in advance.


Ok I solved it. I was not allowed to modify the .so file’s version suffix. When I compile with it correctly links and executes.