# Linking troubles with GLFW

**URL:** https://discourse.glfw.org/t/linking-troubles-with-glfw/1671
**Category:** support
**Created:** [October 9, 2020, 7:24pm UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671 "2020-10-09T19:24:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ajcrm125](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ajcrm125/32/413_2.png) [@ajcrm125](https://discourse.glfw.org/u/ajcrm125)
#### Post date: [October 9, 2020, 7:24pm UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671/1 "2020-10-09T19:24:03Z")

</div>

It has been a long time since I coded in OpenGL and I am looking to get back into it.  
I’ve followed the well-laid out directions here:

> **[LearnOpenGL - Creating a window](https://learnopengl.com/Getting-started/Creating-a-window)**

I’m using MSVS 2012 for WIn10 and am using the pre-compiled GLFW libs for that version.  
I have the include and lib paths setup correctly but when build I get the following error:

error LNK2019: unresolved external symbol \_glfwInit referenced in function \_main C:\Users\acourche\Documents\Visual Studio 2012\Projects\GLFW\_Test\GLFW\_Test\main.obj GLFW\_Test  
error LNK2019: unresolved external symbol \_glfwWindowHint referenced in function \_main C:\Users\acourche\Documents\Visual Studio 2012\Projects\GLFW\_Test\GLFW\_Test\main.obj GLFW\_Test

Which indicates linking error.

I have the libs clearly included in the settings for my project:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/64929b50768ec9b6406daf3bc68c202ee652b085.png)

And the lib path as well.

Is there anything else I’m missing?

Thanks!  
-Adam

---

<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 10, 2020, 9:00am UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671/2 "2020-10-10T09:00:51Z")

</div>

Hi @ajcrm125 welcome to the GLFW forums!

It looks like you are linking to **both** the static library version of glfw, `glfw2.lib` and the dll `glfwdll.lib` when you should only be linking to one or the other.

Note that if you want to link to the dll you need to define `GLFW_DLL` before including the GLFD header.

See the documentation for more information:

> **[GLFW: Building applications](https://www.glfw.org/docs/latest/build.html#build_link_win32)**

If you need still need help with creating a VS project, perhaps take a look at:

> **[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

Using `cmake` you can generate a Visual Studio project with GLFW code built from source.

---

<div class="post-metadata">

### Author: ![ajcrm125](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ajcrm125/32/413_2.png) [@ajcrm125](https://discourse.glfw.org/u/ajcrm125)
#### Post date: [October 15, 2020, 8:37pm UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671/3 "2020-10-15T20:37:55Z")

</div>

Thanks for the info! I tried allowing only 1 of the 2 libs mentioned but still had linker errors.

I then tried the CMake route but came up with some additional issues:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/1db755802f2225415320d78ed79c822b1243e165.png)

Surprised to see so many errors. Is compiling GLFW with CMake supported for Visual Studio 2012?

Thanks  
-Adam

---

<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 15, 2020, 8:57pm UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671/4 "2020-10-15T20:57:31Z")

</div>

Visual Studio 2012 is pretty old, and some of your errors come from compilation issues due to C compatibility issues with older version of Visual Studio.

I recommend installing the Visual Studio 2019 Community version which is free to use.

---

<div class="post-metadata">

### Author: ![ajcrm125](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ajcrm125/32/413_2.png) [@ajcrm125](https://discourse.glfw.org/u/ajcrm125)
#### Post date: [October 15, 2020, 9:00pm UTC](https://discourse.glfw.org/t/linking-troubles-with-glfw/1671/5 "2020-10-15T21:00:48Z")

</div>

Didn’t even know that had a community version. Thanks!
