I tried to download the examples for OpenGL Programming Guide: The Official Guide to Leaning OpenGL, Version 4.5 with SPIR-V and I tried to import the library and include files into my Visual Studio solution so that I can create OpenGL applications with the same file the author used, but I keep on getting these errors:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
GLProgram.obj : error LNK2019: unresolved external symbol gl3wInit referenced in function main
GLProgram.obj : error LNK2019: unresolved external symbol LoadShaders referenced in function "void __cdecl init(void)" (?init@@YAXXZ)
GLProgram.obj : error LNK2001: unresolved external symbol gl3wDrawArrays
GLProgram.obj : error LNK2001: unresolved external symbol gl3wBindBuffer
GLProgram.obj : error LNK2001: unresolved external symbol gl3wEnableVertexAttribArray
GLProgram.obj : error LNK2001: unresolved external symbol gl3wUseProgram
GLProgram.obj : error LNK2001: unresolved external symbol gl3wVertexAttribPointer
GLProgram.obj : error LNK2001: unresolved external symbol gl3wClearBufferfv
GLProgram.obj : error LNK2001: unresolved external symbol gl3wBindVertexArray
GLProgram.obj : error LNK2001: unresolved external symbol gl3wGenVertexArrays
GLProgram.obj : error LNK2001: unresolved external symbol gl3wBufferStorage
GLProgram.obj : error LNK2001: unresolved external symbol gl3wCreateBuffers
C:\Users\saada\Desktop\Visual Studio Projects\OpenGL Programming Guide\OpenGL\OpenGL SPIR-V\x64\Debug\OpenGL SPIR-V.exe : fatal error LNK1120: 12 unresolved externals
What I did was set the include and lib folders from the examples download as the include directories for my project, and then downloaded the glfw3.lib file and linked it, but it appears I am missing something for gl3w. How do I fix, am I missing some .lib file? Here is my code just in case you need it:
#include <vgl.h>
#include <LoadShaders.h>
#define BUFFER_OFFSET(a) ((void*)(a))
enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };
GLuint VAOs[NumVAOs];
GLuint Buffers[NumBuffers];
const GLuint NumVertices = 6;
//----------------------------------------------------------------------------
//
// init
//
void
init(void)
{
glGenVertexArrays(NumVAOs, VAOs);
glBindVertexArray(VAOs[Triangles]);
GLfloat vertices[NumVertices][2] = {
{ -0.90f, -0.90f }, { 0.85f, -0.90f }, { -0.90f, 0.85f }, // Triangle 1
{ 0.90f, -0.85f }, { 0.90f, 0.90f }, { -0.85f, 0.90f } // Triangle 2
};
glCreateBuffers(NumBuffers, Buffers);
glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
glBufferStorage(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 0);
ShaderInfo shaders[] =
{
{ GL_VERTEX_SHADER, "media/shaders/triangles/triangles.vert" },
{ GL_FRAGMENT_SHADER, "media/shaders/triangles/triangles.frag" },
{ GL_NONE, NULL }
};
GLuint program = LoadShaders(shaders);
glUseProgram(program);
glVertexAttribPointer(vPosition, 2, GL_FLOAT,
GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(vPosition);
}
//----------------------------------------------------------------------------
//
// display
//
void
display(void)
{
static const float black[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glClearBufferfv(GL_COLOR, 0, black);
glBindVertexArray(VAOs[Triangles]);
glDrawArrays(GL_TRIANGLES, 0, NumVertices);
}
//----------------------------------------------------------------------------
//
// main
//
int main(int argc, char** argv)
{
glfwInit();
GLFWwindow* window = glfwCreateWindow(800, 600, "Triangles", NULL, NULL);
glfwMakeContextCurrent(window);
gl3wInit();
init();
while (!glfwWindowShouldClose(window))
{
display();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
}
Thanks in advance.
UPDATE: The solution I found was to, not only use my library folder as an include directory, but also include the folder in my project itself.