# Glfw not linking properly in VS Code

**URL:** <https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052>\
**Category:** support\
**Created:** [May 9, 2022, 10:04pm UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052 "2022-05-09T22:04:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/jonas/32/625_2.png) [@Jonas](https://discourse.glfw.org/u/Jonas)\
**Post date:** [May 9, 2022, 10:04pm UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052/1 "2022-05-09T22:04:33Z")

</div>

Jumped ship from VS to VS Code, and although I prefer the editor, I’m having a lot of issues linking libraries. I do manage to link multiple source files, but not actual static libraries. The error I am getting is this:

C:/msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.3.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: C:\Users\jonas\AppData\Local\Temp\ccEJvxZJ.o:C:\Users\jonas\Documents\Koding\Workspaces\multiFileTest/main.cpp:11: undefined reference to `glfwInit’  
tldr; underfined reference to ‘glfwInit’;  
This happens on the glfwTerminate() as well.

My tasks.json looks like this:  
[tasks - Pastebin.com](https://pastebin.com/hgt628tw)

My actual source file looks like this:  
[source - Pastebin.com](https://pastebin.com/PaEBvx9Y)

and my folder structure is non-existant. I have simply copied all dependencies into the same folder as the source code. The gameStuff.cpp and header file is just a test to make sure I got linking a source file working, and it does, so just ignore that. I have included the last four dependencies in the tasks.json as I see a lot of people do it, but I’m not exactly sure where those are coming from.

I tried switching to glfw 64 bit, but just got more warnings. I’m not sure what I’m doing wrong here. Let me know if there is any additional information you would like to resolve this. Seems like many other people are facing the same issue, it is such a shame that no one has gotten any proper solutions yet.

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [May 9, 2022, 10:18pm UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052/2 "2022-05-09T22:18:43Z")

</div>

If you are using g++ from `mingw64` folder (for `x86_64-w64-mingw32` target), then you must use 64-bit `libglfw3.a` library. 32-bit one will **not** work, because 64-bit compiler expects 64-bit static library. What exactly errors are you getting from 64-bit `libglfw3.a` library?

---

<div class="post-metadata">

**Author:** ![Jonas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/jonas/32/625_2.png) [@Jonas](https://discourse.glfw.org/u/Jonas)\
**Post date:** [May 10, 2022, 8:24am UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052/3 "2022-05-10T08:24:05Z")

</div>

Just opened the project, switched the include and lib, aaaand now its working? Perhaps I didn’t include the opengl kernel stuff the last time I tried to use 64bit library. Do you know if there is a way to save this as a template?

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [May 10, 2022, 8:43am UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052/4 "2022-05-10T08:43:54Z")

</div>

Sorry, I don’t use VSCode, no idea how it works.

---

<div class="post-metadata">

**Author:** ![Jonas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/jonas/32/625_2.png) [@Jonas](https://discourse.glfw.org/u/Jonas)\
**Post date:** [May 10, 2022, 9:06am UTC](https://discourse.glfw.org/t/glfw-not-linking-properly-in-vs-code/2052/5 "2022-05-10T09:06:37Z")

</div>

Gotcha, thanks anyway
