# Linking GLFW with /MT

**URL:** <https://discourse.glfw.org/t/linking-glfw-with-mt/274>\
**Category:** support\
**Created:** [June 5, 2011, 8:38pm UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274 "2011-06-05T20:38:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 5, 2011, 8:38pm UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/1 "2011-06-05T20:38:59Z")

</div>

**[jonathanhook](https://sourceforge.net/u/jonathanhook/)** wrote on [Sunday, June 05, 2011](https://sourceforge.net/p/glfw/discussion/247562/thread/971a5c23/#b0ea):

Hi everyone,

I am trying to link a release build of a project that uses GLFW in VS2010  
using the multi-threaded run-time libs (/MT). I’m getting various LNK2005  
errors, so somewhere I assume something isn’t linked against /MT. All the  
other code I’m linking against I’ve compiled myself using /MT (I’ve double-  
double checked!). I’m just using the standard glfw build  
(glfw-2.7.bin.WIN32\glfw-2.7.bin.WIN32\lib-msvc100\release\GLFW.lib).

The weird thing is, I’m sure I’ve compiled this whole project (including  
GLFW) under /MT. Therefore I was wondering if anyone could confirm whether  
GLFW will compile with /MT (as opposed to /MD/MTd etc…) or if anyone else  
has had similar problems? Hopefully then I can discount GLFW being the problem  
and find what else is wrong!!

Thanks for your help in advance.

Jon

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 5, 2011, 10:14pm UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/2 "2011-06-05T22:14:15Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, June 05, 2011](https://sourceforge.net/p/glfw/discussion/247562/thread/971a5c23/#aedd):

There are various issues with the binary package. The safest choice is to  
download the source package and build GLFW yourself with appropriate settings.  
This way, you can make sure that everything matches.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 10, 2011, 7:13pm UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/3 "2011-10-10T19:13:57Z")

</div>

**[plmrdoompl](https://sourceforge.net/u/plmrdoompl/)** wrote on [Monday, October 10, 2011](https://sourceforge.net/p/glfw/discussion/247562/thread/971a5c23/#cfca):

So I’ve tried that and I get crt0dat.c errors. Is that too covered by building  
own glfw library? If so, it’s not helping.

---

<div class="post-metadata">

**Author:** ![Shavais](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shavais/32/630_2.png) [@Shavais](https://discourse.glfw.org/u/Shavais)\
**Post date:** [June 12, 2022, 3:52am UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/4 "2022-06-12T03:52:06Z")

</div>

Hi, I have Windows10 system and I’m using Visual Studio 2022.

I have…

- download glfw-3.3.7 source
- run CMake-GUI
- configured without the use of the msvc runtime dll
- generated the Visual Studio solution/project files
- used Visual Studio 2022 to build glfw3 in debug, release, and the other builds
- checked to make sure the Code Generation in the GLFW project was /MT and not /MD

When I link against the resulting library, if I used /MD in my project it builds fine, but if I use /MT I get a slew of unresolved external symbol errors, like this:

1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol strncmp  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol strncmp  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol strncmp  
1\>glfw3.lib(osmesa\_context.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(wgl\_context.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol free  
1\>glad.obj : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol free  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol free  
1\>glad.obj : error LNK2001: unresolved external symbol strstr  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol strstr  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol strstr  
1\>glad.obj : error LNK2001: unresolved external symbol \_\_stdio\_common\_vsscanf  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol \_\_stdio\_common\_vsscanf  
1\>glad.obj : error LNK2001: unresolved external symbol malloc  
1\>main.obj : error LNK2001: unresolved external symbol \_\_CxxFrameHandler4  
1\>main.obj : error LNK2001: unresolved external symbol \_\_stdio\_common\_vfprintf  
1\>main.obj : error LNK2001: unresolved external symbol \_\_acrt\_iob\_func  
1\>main.obj : error LNK2001: unresolved external symbol exit  
1\>main.obj : error LNK2001: unresolved external symbol \_\_std\_terminate  
1\>TestEvents.obj : error LNK2001: unresolved external symbol “const type\_info::`vftable’” (??\_7type\_info@@6B@)  
1\>LINK : error LNK2001: unresolved external symbol WinMainCRTStartup  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol strncpy  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol strncpy  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol strncpy  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol strncpy  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(wgl\_context.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(osmesa\_context.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol calloc  
1\>glfw3.lib(wgl\_context.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(osmesa\_context.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol \_\_GSHandlerCheck  
1\>glfw3.lib(wgl\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(osmesa\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol \_\_security\_check\_cookie  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol memset  
1\>glfw3.lib(wgl\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(egl\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(osmesa\_context.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(win32\_init.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(context.obj) : error LNK2001: unresolved external symbol \_\_security\_cookie  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(win32\_window.obj) : error LNK2001: unresolved external symbol \_fltused  
1\>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol \_\_stdio\_common\_vsprintf  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol \_\_stdio\_common\_vsprintf  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol strcspn  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol strspn  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol realloc  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol realloc  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol realloc  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol strtoul  
1\>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol memcpy  
1\>glfw3.lib(win32\_monitor.obj) : error LNK2001: unresolved external symbol memcpy  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol qsort  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol qsort  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol memmove  
1\>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol powf  
1\>glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol strcmp  
1\>glfw3.lib(win32\_joystick.obj) : error LNK2001: unresolved external symbol strcmp

What am I missing / doing wrong?

Thanks for any help!

---

<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:** [June 15, 2022, 3:39pm UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/5 "2022-06-15T15:39:49Z")

</div>

Hi @Shavais,

Welcome to the GFLW forum.

On CMake 3.15 and later you can set the standard CMake  
[CMAKE\_MSVC\_RUNTIME\_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) variable instead of this GLFW-specific option - is this what you set?

If you have got /MT properly set in the library build are you then linking to that library when building your library? I can’t thinking of why this wouldn’t work if you have confirmed you are linking with /MT.

You can check if the library is built with /MD by using a dependencies walker like:

> **[GitHub - lucasg/Dependencies: A rewrite of the old legacy software...](https://github.com/lucasg/Dependencies)**
>
> A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues. - GitHub - lucasg/Dependencies: A rewrite of the old legacy softwar...

Binaries are on the releases page: [Releases · lucasg/Dependencies · GitHub](https://github.com/lucasg/Dependencies/releases) and you can run DependenciesGui.exe and then drag the library onto the window to see the libraries it uses.

If you see VCRUNTIME140.DLL (or similar depending on the platform toolset you are using) then you have linked with /MD.

---

<div class="post-metadata">

**Author:** ![Shavais](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shavais/32/630_2.png) [@Shavais](https://discourse.glfw.org/u/Shavais)\
**Post date:** [July 27, 2022, 7:14am UTC](https://discourse.glfw.org/t/linking-glfw-with-mt/274/6 "2022-07-27T07:14:50Z")

</div>

Hi, thanks for your reply! Somehow, while I’ve been getting GLFW emails for a while, now, I missed the notification about it until now. I tried, at the time, to make sure I was building against the correct library, but it occurs to me now that I may not have manually deleted all the potentials and then rerun the build with /MT to make sure the only potentials would be built with /MT. Anyway, I gave up trying to get /MT to work and I’ve just been using /MDd and /MD for the moment. But I’d prefer not to ship the .dll alongside my program, so, at some point I’ll have to dedicate some time to trying again to troubleshooting this. I’ll look for where you set that CMake variable. Anyway thanks again and when I eventually get back to this I’ll try to find and update this thread.
