Configuring GLFW with MinGW

I am trying to learn OpenGL using GLFW, but I am having some problems.

This is my main.cpp:

#include <GL/glfw.h> int main() { glfwInit(); glfwSleep( 1.0 ); glfwTerminate(); } 

This is my project folder structure:

 Project +- glfw.dll +- main.cpp 

Here I extracted the GLFW files:

 MinGW +- include | +- GL | +- glfw.h +- lib +- libglfw.a +- libglfwdll.a 

And this is how I try to create a program:

 g++ main.cpp -o main.exe -lglfwdll 

And these are the errors I get:

 C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0xf): undefined reference to `_glfwInit' C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0x25): undefined reference to `_glfwSleep' C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0x2a): undefined reference to `_glfwTerminate' collect2.exe: error: ld returned 1 exit status 

Did I miss something?

+4
source share
1 answer

Download binaries here to suit your environment.

 Project +- glfw3.dll (You can put it in System32 or SysWOW64 instead.) +- main.cpp MinGW +- include | +- GLFW | +- glfw3.h +- lib +- libglfw3.a +- libglfw3dll.a (Renamed from glfw3dll.a) g++ -c main.cpp g++ -o main.exe main.o -lglfw3dll -lopengl32 
+3
source

Source: https://habr.com/ru/post/1439697/


All Articles