0

I'm attempting to follow the tutorial on learnopengl.com and I've created a directory on my C: drive to house my include and lib folders. I then linked them to Visual Studio 2019 and included the proper header files.

#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>

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_OPENGL_FORWARD_COMPAT, GL_TRUE);

    return 0;
}

I get 2 errors from this:

unresolved external symbol glfwInit referenced in function main
unresolved external symbol glfwWindowHint referenced in function main

What could cause this?

I have looked for similar questions to mine but was unsuccessful.

REDACTED
  • 31
  • 7
  • Either include path is incorrect or library path is incorrect or library name is incorrect or the linked library is incompatible for your platform (or maybe runtime?). – kiner_shah Feb 16 '22 at 05:06
  • I'd think so too, but I triple checked, and even replaced it with the autogenerate from open folder to make sure. The include and library paths are correct. – REDACTED Feb 16 '22 at 05:08
  • 1
    is `#include ` right? how about `#include "GLFW/glfw3.h"` ans so on? – K.R.Park Feb 16 '22 at 05:11
  • In addition to telling the compiler where to look for libraries you also need to tell it which libraries to look for. You may have set the library directory correctly but not specified the actual libraries to link. – Retired Ninja Feb 16 '22 at 05:15
  • would it have anything to do with .dll's? I didn't do anything with them while setting this up. – REDACTED Feb 16 '22 at 05:20
  • Did you explicitly list the lib files in project properties -> Linker -> Input -> Additional Dependencies or add `#pragma comment(lib, "libraryname.lib")` lines to your source code to add the dependency? – Retired Ninja Feb 16 '22 at 05:25
  • Another alternative is to build glfw3 statically and link it into your executable: in CMake, set `BUILD_SHARED_LIBS` to `off` or uncheck it if you're using CMake's GUI, build the project and get a `glfw3.lib` and a `glfw3.pdb`, then in your IDE, add the path to the two files to linker's additional static library dirs (not the one for headers). – Oasin Feb 16 '22 at 05:40
  • You need to show your actual compilation and linking commands (look for "Command Line" under C/C++ and Linker in the properties dialog, or find them in your build log). – n. m. could be an AI Feb 16 '22 at 08:41

0 Answers0