# Init no-go! this should be super easy

**URL:** <https://discourse.glfw.org/t/init-no-go-this-should-be-super-easy/977>\
**Category:** support\
**Created:** [September 4, 2017, 9:22pm UTC](https://discourse.glfw.org/t/init-no-go-this-should-be-super-easy/977 "2017-09-04T21:22:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TenSeven](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/tenseven/32/123_2.png) [@TenSeven](https://discourse.glfw.org/u/TenSeven)\
**Post date:** [September 4, 2017, 9:22pm UTC](https://discourse.glfw.org/t/init-no-go-this-should-be-super-easy/977/1 "2017-09-04T21:22:10Z")

</div>

Just doing the super-basics here, getting GLFW3 initialized. Surprisingly using the suggested site code, I can’t compile (or maybe it is) and a linker issue. Probably compile settings/library/IDE IDK, but it should be very straightforward.  
Repost the suggested init code, followed my compile errors. Any help would be greatly appreciated !!

```auto
g++ -std=c++0x -std=c++11 "-IC:\\bil_inc_lib\\include" "-includeC:\\bil_inc_lib\\include\\glfw3.h" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\main.o" "..\\src\\main.cpp" 
g++ "-LC:\\bil_inc_lib\\library" -o GLFW_test_prog.exe "src\\main.o" -lglfw3 -lopengl32 

```

Init Code:

```c
#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;
}

```

Errors:

```auto
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x3f6): undefined reference to `CreateDCW@16'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x40b): undefined reference to `GetDeviceCaps@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x420): undefined reference to `GetDeviceCaps@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x43d): undefined reference to `DeleteDC@4'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x5db): undefined reference to `CreateDCW@16'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x5f2): undefined reference to `GetDeviceCaps@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x60b): undefined reference to `GetDeviceCaps@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x62c): undefined reference to `DeleteDC@4'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xba6): undefined reference to `CreateDCW@16'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xbbb): undefined reference to `GetDeviceGammaRamp@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xbc6): undefined reference to `DeleteDC@4'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xe35): undefined reference to `CreateDCW@16'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xe46): undefined reference to `SetDeviceGammaRamp@8'
C:\bil_inc_lib\library/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xe51): undefined reference to `DeleteDC@4'
C:\bil_inc_lib\library/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xc1): undefined reference to `CreateDIBSection@24'
C:\bil_inc_lib\library/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x10e): undefined reference to `CreateBitmap@20'
C:\bil_inc_lib\library/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1a9): undefined reference to `DeleteObject@4'
C:\bil_inc_lib\library/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1b4): undefined reference to `DeleteObject@4'
C:\bil_inc_lib\library/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x239): undefined reference to `DeleteObject@4'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x151): undefined reference to `SwapBuffers@4'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x424): undefined reference to `DescribePixelFormat@16'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x4fb): undefined reference to `DescribePixelFormat@16'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x635): undefined reference to `DescribePixelFormat@16'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x656): undefined reference to `SetPixelFormat@12'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x105d): undefined reference to `ChoosePixelFormat@8'
C:\bil_inc_lib\library/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1070): undefined reference to `SetPixelFormat@12'
collect2.exe: error: ld returned 1 exit status

```

---

<div class="post-metadata">

**Author:** ![TenSeven](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/tenseven/32/123_2.png) [@TenSeven](https://discourse.glfw.org/u/TenSeven)\
**Post date:** [September 4, 2017, 10:13pm UTC](https://discourse.glfw.org/t/init-no-go-this-should-be-super-easy/977/2 "2017-09-04T22:13:33Z")

</div>

Added **gdi32** to library, problem(s) solved.

Why do we need more than the header though in this case?

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [September 4, 2017, 10:44pm UTC](https://discourse.glfw.org/t/init-no-go-this-should-be-super-easy/977/3 "2017-09-04T22:44:34Z")

</div>

> [@TenSeven](#):
>
> Why do we need more than the header though in this case?

MinGW never added gdi32 to the set of default libraries, unlike Visual Studio. It’s briefly mentioned [here](http://www.glfw.org/docs/latest/build.html#build_link_win32) but that should probably be more prominent. Alternatively GLFW should load it dynamically like it does with system libraries not in the Visual Studio defaults.
