I have downloaded GLFW 3.3.2 for Windows 32 binaries
I have wrote this code to generate empty window using C++ and visual studio
/* Initialize the library */
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
/* Make the window's context current */
/* Loop until the user closes the window */
/* Render here */
/* Swap front and back buffers */
/* Poll for and process events */
and when i build it gives me this error
1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1>libglfw3.lib(init.c.obj) : error LNK2019: unresolved external symbol ___ms_vsnprintf referenced in function __glfwInputError
1>C:\amin\MyApplication\opengl\Project1\Debug\Project1.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project “Project1.vcxproj” – FAILED.
Welcome to the GLFW forum!
Do check out the guide to Building Applications with GLFW, paying particular attention the libraries you need to link to.
Additionally you may find that using this GLFW starter project with CMake is an easier way to create the Visual Studio project you need.
yes I have checked it
and aready linked these liberarys
My recommendation would be to try the GLFW starter project with CMake.
I’m confused as to where you got
libglfw3.lib from - did you build this yourself? The name of the Visual Studio pre-built libraries is
glfw3.lib for static libraries and
glfw3dll.lib for DLLs. These should be in a directory called lib-vc20XX where 20XX is the version of Visual Studio you are using - for example 2019. You can get these from here:
If you want to create a project from scratch with Visual Studio, then a good approach would be to use the project wizard in Visual Studio to create a “Hello World” console application and then go from there - I have checked and this has the correct linker settings to work with vsnprintf at least with Visual Studio 2019. You shouldn’t need legacy_stdio_definitions.lib.
Yeah this sounds like a misunderstanding of building and linking libraries and less about any confusion with GLFW. As an aside, “unresolved external symbol” and “unresolved externals” means that something went wrong in linking.
Simplest way to do it is…
- Download the GLFW source.
- Create a static library visual studio project with CMake.
- Open the new project and compile the solution.
- Grab the created libraries and include and link them in your project.
For a basic GLFW project on windows, all you should have to include is glfw3.lib and opengl32.lib.
As an aside, your code looks to be correct, once you get the linking issue corrected.