1 unresolved externals

unresolved external symbol __imp_glClear referenced in function main
1 unresolved externals

Trying to set up 64x GLFW, had the 11 unresolved errors but fixed it. I’m on VS 2019. Here’s what I’ve done so far:

Changed Config>Linker>General>Additional Library Directories to lib.
Added glfw3dll.lib and glfw3.lib to Config>Linker>Input>Additional Dependencies
Changed Config>General>C/C++>Additional Include Directories to include.

Not sure where I went wrong, tried looking up the error to no avail

glClear is an OpenGL function, which on windows requires you to link to opengl32.lib by adding it to your Linker->Input->Additional Dependencies. It’s a system library so you don’t need to add any include directories.

For GLFW you should ONLY link either glfw3.lib or glfw3dll.lib depending on whether you want the static or dynamic library, see GLFW: Building applications.

Okay, now it opens the window and loads everything but it gives the error “The code execution cannot proceed because glfw3.dll was not found. Reinstalling the program may fix this problem.”

If you are dynamically linking the dll with glfw3dll.lib then you need to put place the dll somewhere the system will find it. My recommendation is to place it in the same folder as your executable is output to.

What’s the difference between static and dynamic out of curiosity?

In static linking the linker (which runs after the compiler) adds the object file which contains the compiled code to your executable.

In dynamic linking the linker doesn’t add the code to your executable, but adds data to ensure that when the program is run the correct library (.dll for Windows, .so for Linux etc.) is loaded at run time. There are further details, but this covers the basics.

It is thus possible to change a dynamically linked library without modifying the executable. This allows bugs to be fixed in system libraries without changing any installed executables. Games on PCs often put game specific logic into a dll which can then be modified by end users - i.e. code mods.

Since GLFW is fairly small, using a statically linked library is usually the best approach.

There’s a good introduction to linkers here:

1 Like