I am trying to develop an openGL application with GLEW and GLFW on Windows using minGW. In the current directory, project/
, I have the directories src/
, bin/
, and glfw-3.0.4.bin.WIN64/
. I have the files test.cpp
, glew.h
, glew.c
, and wglew.h
in the src/
directory.
The directory ./glfw-3.0.4.bin.WIN64/include/
contains the GLFW/glfw3.h
header file.
The directory ./glfw-3.0.4.bin.WIN64/lib-mingw/
contains glfw3.dll
, glfw3dll.a
, and libglfw3.a
.
My main file, test.cpp
contains,
#include "glew.h"
#include "GLFW/glfw3.h"
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello, World!\n");
glewInit();
glfwInit();
}
I am compiling the program from the project/
directory by running (split into two lines for readability)
gcc -DGLEW_STATIC -DGLFW_DLL -o ./bin/test ./src/*.cpp ./src/glew.c
-I ./glfw-3.0.4.bin.WIN64/include/ -L ./glfw-3.0.4.bin.WIN64/lib-mingw/ -lglfw3 -lopengl32
and I am getting the following error:
undefined reference to `_imp_glfwInit'
I think the problem has to do with me linking the GLFW library incorrectly. From what I understand, including the compiler option -lglfw3
will tell gcc to link ./glfw-3.0.4.bin.WIN64/lib-mingw/glfw3.dll
, which contains the definition for glfwInit()
.
I've looked at solutions to other problems similar to mine and they suggest things such as copying the dll file to the source/binary directories and changing the order of the -l options, but none have seemed to solve the problem for me.
-Ipath
and-Lpath
must be written without space. – Mitchum