# Compiling a GLFW demo file without GLAD

**URL:** <https://discourse.glfw.org/t/compiling-a-glfw-demo-file-without-glad/1682>\
**Category:** support\
**Created:** [October 28, 2020, 11:27am UTC](https://discourse.glfw.org/t/compiling-a-glfw-demo-file-without-glad/1682 "2020-10-28T11:27:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![somerandompiggo](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@somerandompiggo](https://discourse.glfw.org/u/somerandompiggo)\
**Post date:** [October 28, 2020, 11:27am UTC](https://discourse.glfw.org/t/compiling-a-glfw-demo-file-without-glad/1682/1 "2020-10-28T11:27:47Z")

</div>

I’m trying to compile this demo file that I found online without GLAD (just as a test). I’m using GCC on Ubuntu 20.04 and have tried these compiler options:  
-lglfw3  
-lglfw  
-lopengl32

At first I tried to compile GLFW from scratch but couldn’t so tried installing libglfw3-dev  
Right now I’m still using FreeGLUT but I prefer GLFW. Here is the code

#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;

```

}

-lglut worked, kinda. It compiled without saying it doesn’t exist but gives the error “glClear not found”. Thanks!

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [October 28, 2020, 11:47am UTC](https://discourse.glfw.org/t/compiling-a-glfw-demo-file-without-glad/1682/2 "2020-10-28T11:47:16Z")

</div>

Hi @somerandompiggo,

Welcome to the GLFW forum!

You don’t need glut3 nor glut, but you will need OpenGL (not opengl32, that’s for MS Windows) and glfw3.

Check out the compilation guide for using pkg-config as this is the easiest approach: [https://www.glfw.org/docs/latest/build\_guide.html#build\_link\_pkgconfig](https://www.glfw.org/docs/latest/build_guide.html#build_link_pkgconfig)

Since you are using OpenGL directly the compilation command would look something like:

```auto
cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl)

```

Also do check out our minimal GLFW cmake starter:

> **[juliettef/GLFW-CMake-starter](https://github.com/juliettef/GLFW-CMake-starter)**
>
> Use CMake to create a project with GLFW - Multi-platform Windows, Linux and MacOS. - juliettef/GLFW-CMake-starter

---

<div class="post-metadata">

**Author:** ![somerandompiggo](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@somerandompiggo](https://discourse.glfw.org/u/somerandompiggo)\
**Post date:** [October 28, 2020, 1:09pm UTC](https://discourse.glfw.org/t/compiling-a-glfw-demo-file-without-glad/1682/3 "2020-10-28T13:09:27Z")

</div>

Oh, thats why it looked wrong. I meant -glfw and -glfw3. Ill edit the post. Sorry
