Search code examples
linuxexecutablecodeblockslinux-mint

Code Blocks output doesn't execute linux


I am pretty new to linux and i wanted to try to make a small opengl program just as a test. I'm using glfw and i made a very easy test:

    #include <iostream>
    #include <GL/glew.h>
    #include <GLFW/glfw3.h>

    using namespace std;

    int main()
    {
        if (!glfwInit())
        {
            return -1;
        }
        GLFWwindow *window = glfwCreateWindow(800, 600, "Het werkt", NULL, NULL);
        if (!window)
        {
            glfwTerminate();
        }
        glfwMakeContextCurrent(window);

        while (!glfwWindowShouldClose(window))
        {
            glfwPollEvents();
            glfwSwapBuffers(window);
        }
    }

Now if i try to run this in Code::Blocks itself, it runs fine, debug, release, it doesn't matter, it works. But when i try to execute it outside Code::Blocks, it goes wrong. If i double click the executable nothing happens, and if i ./ExecutableName in the terminal it gives me this error:

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

All of the libs are in the same directory as the executable, so i don't get why it gives this error.

By the way i'm working on Linux Mint.

Thanks in advance for your help!


Solution

  • You should place those libraries in your $PATH. Issue a echo $PATH command and see if you can find the libraries in there (within those paths) - if not, you will have to put them in there someway. I'm not sure if you can just copy-paste the libraries in there, so probably you may want to search for them using your linux distribution's package management system. As you are using Linux Mint, maybe you could try searching with sudo aptitude search glfw and then try installing the corresponding packages.