Photon
Photon

Reputation: 2777

Linking errors in visual studio 2015

When trying to build project I got an error cannot open file "kernel32.lib", after some googling I added $(LibraryPath) on the end of Library directories.

enter image description here

By doing that I got rid of previous error, yet now I get a bunch of other ones:

enter image description here

And Here`s my code:

    //GLEW
#define GLEW_STATIC
#include <glew.h>
//GLFW
#include <glfw3.h>
#include <iostream>

int main()
{
    glfwInit();

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    GLFWwindow* window = glfwCreateWindow(800, 600, "Learning OpenGL :)", nullptr, nullptr);

    if (window == nullptr)
    {
        std::cout << "Failed to create window\n";
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    glewExperimental = GL_TRUE;

    if (glewInit() != GLEW_OK)
    {
        std::cout << "failed to initialize GLEW\n";
        return -1;
    }

    glViewport(0, 0, 800, 600);

    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        glfwSwapBuffers(window);
    }

    glfwTerminate();
    return 0;
}

How can I fix all those linking errors and finally get my program running?

Upvotes: 0

Views: 599

Answers (1)

Zebrafish
Zebrafish

Reputation: 14110

This works on my compiler, but I have all the stuff linked properly I guess. All I have is the same stuff you have, plus the linked libraries in the actual code. Try paste:

#pragma comment (lib, "glew32s.lib")
#pragma comment (lib, "glfw3.lib")
#pragma comment (lib, "OpenGL32.lib")

Before your main. Make sure glew.h is included BEFORE glfw headers. And make sure your library folders point to where these files are.

Upvotes: 1

Related Questions