Home > Back-end >  The error LNK2001: cannot resolve _glad_glViewport external symbol
The error LNK2001: cannot resolve _glad_glViewport external symbol

Time:11-12

Learning OpenGL compile meet this problem, a headache for half a day time, who can you help me to solve my

#include
#include

#include

Void framebuffer_size_callback (GLFWwindow * window, int width, int height);

//Settings
Const unsigned int SCR_WIDTH=800;
Const unsigned int SCR_HEIGHT=600;

Int main ()
{
GlfwInit ();
GlfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
GlfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
GlfwWindowHint (GLFW_OPENGL_PROFILE GLFW_OPENGL_CORE_PROFILE);

GLFWwindow * window=glfwCreateWindow (SCR_WIDTH SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
If (window==NULL)
{
STD: : cout & lt; <"Failed to create GLFW window" & lt; GlfwTerminate ();
return -1;
}
GlfwMakeContextCurrent (Windows);
GlfwSetFramebufferSizeCallback (window, framebuffer_size_callback);
if (! GladLoadGLLoader (GLADloadproc glfwGetProcAddress))
{
STD: : cout & lt; <"Failed to initialize GLAD" & lt; return -1;
}
while (! GlfwWindowShouldClose (Windows))
{
GlfwSwapBuffers (Windows);
GlfwPollEvents ();
}
GlfwTerminate ();
return 0;
}

Void framebuffer_size_callback (GLFWwindow * window, int width, int height)
{
GlViewport (0, 0, width, height);
}

1> -- -- -- -- -- - has started to generate: project: ConsoleApplication3, configuration: Debug Win32 -- -- -- -- -- --
1> First, the CPP
1> First. Obj: error LNK2019: cannot resolve _gladLoadGLLoader external symbols, the symbol referenced in the function _main
1> First. Obj: error LNK2001: cannot resolve the external symbol of _glad_glViewport
1> E: \ OpenGL \ OpenGL_Study \ First \ Debug \ ConsoleApplication3 exe: fatal error LNK1120:2 cannot resolve the external command
1> Generating project has been completed "ConsoleApplication3 vcxproj" operations - failure,
==========: zero success, failure, the latest zero, skip the 0==========

CodePudding user response:

Must first determine the build is an empty project (empty project), if not glad, c will conflict with other header files,
Contains directories and cohesion libraries pay attention to have to set it,
After establishing the project to build a new CPP file with the original code, and then right at the first folder to add glad. Is able to run normally after ~ c file

CodePudding user response:

You need to put the glad. C files added to the project,

CodePudding user response:

Positive solution to second floor

CodePudding user response:

The glad. C files added to the project of concrete is to point to?? what

CodePudding user response:

Download glad..lib file, add dependent libraries, with respect to OK

CodePudding user response:

Visual is not glad. C file is added to the project, or added to the project the vs not detected,
Suggestion: add a source files in the project glad. C (or glad. CPP), the glad. C file content intact kao in the past, save

CodePudding user response:

Upstairs brother positive solution, I also encountered the same problems, thought the glad. C in the same folder. In fact you need to add into engineering. Right-click the source file - & gt; Add existing item - & gt; It is ok to find glad. C added.

CodePudding user response:

# 7 brother thumb up

CodePudding user response:

See my blog:
https://blog.csdn.net/gongzhu110/article/details/80032602

CodePudding user response:

If you add glad. C and was glad. C file compiler error name class can't find xcode what's the problem

CodePudding user response:

Will be glad. C files added to the current project, can solve the problem, try to kiss
  • Related