-1

I am trying to make a 3d game in C++ with glfw and opengl but I'm getting a lot of linker errors.

Errors

I've tried changing some linker settings but nothing I tried worked.

I'm using the example glfw code

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    if (!glfwInit())
        return -1;

    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);
    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}
  • What are you passing to the linker on the command-line? Looks like you are not passing the library. – Neil May 08 '21 at 22:40
  • Find where your glfw `.lib` file is, copy the full path including the filename. Right click on your project, select properties, click on Linker, then on Input. Paste into Additional Dependencies. – Accumulator May 08 '21 at 22:45
  • I'm already doing that and when I look at the .cpp file it does not say anything is erroring but when I try to build it outputs all those errors. – patriik May 08 '21 at 22:51

1 Answers1

0

I can't tell where the exact problem is without seeing your linker / compiler options, but these suggestions might solve your problem:

  • If you are linking against a dll, you will need to define GLFW_DLL as a preprocessor macro
  • Make sure that your linker can find glfw3.lib or glfw3dll.lib
  • You have to link against glfw3dll.lib if you want to link against the dll

There is a Guide on how to build apps with glfw on their website.

Lars
  • 68
  • 6