# Can't get OpenGL to work with SDL2

**URL:** <https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948>\
**Category:** SDL Development\
**Created:** [September 3, 2014, 4:29am UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948 "2014-09-03T04:29:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelveticaStan](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/dc4da7/32.png) [@HelveticaStan](https://discourse.libsdl.org/u/HelveticaStan)\
**Post date:** [September 3, 2014, 4:29am UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948/1 "2014-09-03T04:29:04Z")

</div>

No matter what I try, I get this error when trying to use any gl\_ function in my code  
error LNK2019: unresolved external symbol \_\_imp\_\_glClear at 4 referenced in function \_SDL\_main

Can anyone give me exact instructions how to set it up properly? When I google, the results either show tutorials for SDL 1.2 or use GLEW, is there even any point in using GLEW with SDL2? I thought all of the OpenGL context functionality is provided.

---

<div class="post-metadata">

**Author:** ![mr\_tawan](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mr_tawan/32/85_2.png) [@mr\_tawan](https://discourse.libsdl.org/u/mr_tawan)\
**Post date:** [September 3, 2014, 1:16pm UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948/2 "2014-09-03T13:16:21Z")

</div>

what is your link flag (-l) ?

---

<div class="post-metadata">

**Author:** ![Maleachi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@Maleachi](https://discourse.libsdl.org/u/Maleachi)\
**Post date:** [September 3, 2014, 8:49am UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948/3 "2014-09-03T08:49:36Z")

</div>

> GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform.

Afaik you need glew to get the function pointers from all opengl functions from the driver.  
it is a bit out of scope of sdl to provide that as well.

---

<div class="post-metadata">

**Author:** ![HelveticaStan](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/dc4da7/32.png) [@HelveticaStan](https://discourse.libsdl.org/u/HelveticaStan)\
**Post date:** [September 3, 2014, 9:32am UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948/4 "2014-09-03T09:32:58Z")

</div>

Well, even with GLEW properly set up it does the same thing.

---

<div class="post-metadata">

**Author:** ![HelveticaStan](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/dc4da7/32.png) [@HelveticaStan](https://discourse.libsdl.org/u/HelveticaStan)\
**Post date:** [September 4, 2014, 9:41am UTC](https://discourse.libsdl.org/t/cant-get-opengl-to-work-with-sdl2/20948/5 "2014-09-04T09:41:12Z")

</div>

Fixed it by adding Opengl32.lib to additional libraries.
