Why link error when try to build simple OpenGL project?

naseeam used Ask the Experts™
I'm using Visual Studio Community 2019.
I found 'OpenGL C++ Tutorial : Getting Started' on youtube.   I get error when I try to link project.  Maybe I'm not specifying 'Additional Dependencies' correctly in my project setting.  Please see attached.

Also, attached is the link error.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


I downloaded 32-bit GLFW library.  Since I have 64-bit machine, do I need to download 64-bit windows library instead?
Inaddidional  independence  include extensión: glfw3.lib;...
Remove from adicional depende glfw3
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.


I added file extension in 'Additional Dependencies', now I get following link error:

link error


Initially, before adding libraries to 'Additional Dependencies', I deleted everything from this field and then added libraries told by the
youtube tutorial.  Does %(Additional Dependencies) need to be at the end of 'Additional Dependencies' field?

Do I need to specify path to the glfw library in visual studio?
Yes, you need to include library path in VC Directories:
Include Directory

Library Directory

First for .h and sec9nd for objetos and .h.

Ignore my previous coments and ensure you are include the path en VCDirectorie


Build succeeded but following linker warning?

linker warning
Conflits between c++ libs and glfw3 libs: Verify that both libraries have the same threading:  Multithread / Not Multithread.

maybe you are compiling your project as multithraead and the libraries are not multithread


My project only has One function, main( ).  There are no threads in this function.  

#include <GLFW/glfw3.h>

int main(void)
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
        return -1;

    /* Make the window's context current */

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
        /* Render here */

        /* Swap front and back buffers */

        /* Poll for and process events */

    return 0;

Open in new window

I  downloaded 32-bit Windows binaries from:  https://www.glfw.org/download.html.  Is this the reason for linker warning?

Instead of binaries, downloading 'Source Package' and compiling into library will eliminate this warning?
Your are using glfw3 for lib-vc2019.  Yor visual studio is 2019?  If not then change the libraries and include Directories in VCDirectories configuration to lib-yourvsversion.

The reason of the warnning is different msvcrt runtime
Included Directory is then same only modify in LIbraries Dictories lib-vc2019 to lib-vc2010 if you are using vs 2010 for example


I'm using Visual Studio Community 2019

General Configuration:

Platform Toolset : visual Studio 2019 (v142)


Use Runtime Libraru: /MD
Alternative: create New project and install glfw library from Nuget Package Administrator.
Using: Runtime Library:  /MD no warnings. Default is /MDd for debug y /MD for Realease (no debug simbols).  Library glfw3.lib  is Release no debug this is reason of warnning.


What is " /NODEFAULTLIB:library "  Do I need to use some no default library instead of 'MSVCRT' ?

No, ID you use NODEFAULTLINK then linker ignore the default libraries to resolve external  referentes.
I reproduced the problem in my computer and the reason for the warnning is that the library glfw3.lib is a final version without symbols for debugging. In Visual Studio by default you are in debug mode. for that reason when generating the executable with a library that is not debugging, the warnings come out. however if you go to release mode you will see that the warning disappears. If you do not want to see the warning in debug mode then you must put the / MD parameter. Preferable is that you ignore the warning when you are in debug mode.
When you have the final version of the program, go to Release mode to compile it and you will see that the warning disappears.
remember: when you change to Release you will have to configure the inclusion directories and libraries, as well as the additional libraries again for this environment


Expert found root cause of compiler warning.  Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial