Linking error building project in Visual Studio that uses glfw3.lib

Hi,

I am facing a problem building a project that uses GLFW.

What I tried:

  1. First, I download the source code and built it as library (glfw3.lib). It was successful.
  2. I tried to build a project that uses this library. I encountered these error messages at the linking phase:
    2>glfw3.lib(window.obj) : error LNK2019: unresolved external symbol __imp_strncpy referenced in function glfwWindowHintString
    2>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp_strncpy
    2>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp_strncpy
    2>glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp_strncpy
    2>glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function sscanf

Here is the screen capture, showing the option /MD selected. I read that it could me something related to this option in Code Generation → Runtime Library, but I tried all the options (/MD, /MDd, /MT and /MTd) and none worked.

What can I do to solve this problem? Maybe use a precompiled binary?

I forgot to mention that I am using Windows 10 and trying to build to Windows.

Hi @samuelmorais,

Welcome to the GLFW forum.

This looks like you do indeed have your Runtime Library set to a different version in the GLFW project than in the project you are compile with. Can you check what Runtime Library you are compiling the project which uses the library and make sure you use the same one in that project as in GLFW?

You might find that this GLFW CMake Starter could be useful in comparing the compile and link options of both GLFW and the GLFW-CMake-starter prject which links to it alongside your own solution.

Cheers,

Doug.