Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22015

GCC: GLFW undefined reference to `glfwCreateWindow' [duplicate]

$
0
0

I created the ./hello-glfw folder. and I have an index.c file. Here's what my file looks like

#include <GLFW/glfw3.h>int main(void){    GLFWwindow* window;    /* Initialize the library */    if (!glfwInit())        return -1;    /* Create a windowed mode window and its OpenGL context */    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);    if (!window)    {        glfwTerminate();        return -1;    }    /* Make the window's context current */    glfwMakeContextCurrent(window);    /* Loop until the user closes the window */    while (!glfwWindowShouldClose(window))    {        /* Render here */        glClear(GL_COLOR_BUFFER_BIT);        /* Swap front and back buffers */        glfwSwapBuffers(window);        /* Poll for and process events */        glfwPollEvents();    }    glfwTerminate();    return 0;}

I cloned the glfw REPO and built it, then put GLFW(/include/GLFW) in my /usr/include/Then I try to compile it using GCC.

gcc index.c

/usr/bin/ld: /tmp/cc1qGkzK.o: in function `main':index.c:(.text+0x9): undefined reference to `glfwInit'/usr/bin/ld: index.c:(.text+0x35): undefined reference to `glfwCreateWindow'/usr/bin/ld: index.c:(.text+0x45): undefined reference to `glfwTerminate'/usr/bin/ld: index.c:(.text+0x58): undefined reference to `glfwMakeContextCurrent'/usr/bin/ld: index.c:(.text+0x64): undefined reference to `glClear'/usr/bin/ld: index.c:(.text+0x70): undefined reference to `glfwSwapBuffers'/usr/bin/ld: index.c:(.text+0x75): undefined reference to `glfwPollEvents'/usr/bin/ld: index.c:(.text+0x81): undefined reference to `glfwWindowShouldClose'/usr/bin/ld: index.c:(.text+0x8a): undefined reference to `glfwTerminate'collect2: error: ld returned 1 exit status

can't the compiler find the .lib ?

Here is my opengl version.OpenGL version string: 3.0 Mesa 19.3.1

Thank you in advance!


Viewing all articles
Browse latest Browse all 22015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>