0

I am just starting to get into C++ coding, specifically OpenGL (GLFW at this stage). I am using MinGW, and compiling my code using a batch file:

g++ -time -v -I lib/glfw-3.1.2/include -o "bin/OpenGL Test" src/Main.cpp

My test code is this:

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

using namespace std;

int main() {
    if(!glfwInit()) {
        return 1;
    }
    glfwTerminate();
    return 0;
}

To me this seems like it should compile and run correctly, but it throws errors at the two GLFW functions, claiming that they are 'undefined references'.

What have I done wrong?

Arkathorn
  • 69
  • 1
  • 2
  • 8

1 Answers1

0

'undefined references' is a common error. You should compile your cpp first. Then link it with the library to form executable file.

Scott Deng
  • 119
  • 8