I'm trying to learn OpenGL with GLFW, but I'm having some problems.
This is my main.cpp:
#include <GL/glfw.h>
int main()
{
glfwInit();
glfwSleep( 1.0 );
glfwTerminate();
}
This is my project's folder structure:
Project
+- glfw.dll
+- main.cpp
This is where I extracted the GLFW files:
MinGW
+- include
| +- GL
| +- glfw.h
+- lib
+- libglfw.a
+- libglfwdll.a
And this is how I try to build the program:
g++ main.cpp -o main.exe -lglfwdll
And these are the errors I'm getting:
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
Am I missing something?
g++ ... -L /path/to/lib
also remember that MinGW uses a different set of ABIs from Visual Studio, so be sure that all the libraries that you are using for MinGW are compiled for MinGW. – TestisD:\Dropbox\C++\Untitled
where glfw.dll is located, but without success, and tbe .zip file I downloaded had a separatelib-mingw
folder, so I assume these are the right libraries. – Sherburng++ -print-search-dirs
this command will print all the paths considered by g++, if the lib it's not here you need to add it with the-L
option. There can be other problems but I'm currently not programming on Windows, and I'm not touching Windows since days and months, but you can get really nasty behaviours like user restrictions from the UAC or different ABI standards. If you want to solve this just use Codeblocks and you will use the same MinGW that you are using now and, at least, you got support for it. Most of this problems are just caused by the Windows OS and not by MinGW itself. – Testis