I struggled with finding documentation on compiling a basic OpenGL/GLFW example Windows using Cygwin-g++ so I decided to post an answer to my own question.
#define GLFW_DLL
#include <GLFW/glfw3.h>
#include <iostream>
int main(void) {
std::cout << "Code works" << std::endl;
if (!glfwInit())
return -1;
glfwTerminate();
return 0;
}
g++ -Wall -Iinclude main.cpp -o main.exe -L<folder glfw3.dll is in> -lglfw3 -lopengl32 -lgdi32
Issues
undefined reference
errors.alternative solution building the GLFW for Cygwin
Download glfw-3.3.4.zip and then
$ unzip glfw-3.3.4.zip
$ cd glfw-3.3.4
$ ccmake .
set BUILD_SHARED_LIBS to ON. Configure and generate
$ make
$ make install
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/include/GLFW
-- Up-to-date: /usr/local/include/GLFW/glfw3.h
-- Up-to-date: /usr/local/include/GLFW/glfw3native.h
-- Up-to-date: /usr/local/lib/cmake/glfw3/glfw3Config.cmake
-- Up-to-date: /usr/local/lib/cmake/glfw3/glfw3ConfigVersion.cmake
-- Up-to-date: /usr/local/lib/cmake/glfw3/glfw3Targets.cmake
-- Up-to-date: /usr/local/lib/cmake/glfw3/glfw3Targets-noconfig.cmake
-- Up-to-date: /usr/local/lib/pkgconfig/glfw3.pc
-- Up-to-date: /usr/local/lib/libglfw.dll.a
-- Up-to-date: /usr/local/bin/cygglfw-3.dll
So you will have a proper Cygwin build installed under /usr/local
after that, running under X server
$ g++ main.cpp -o main -lglfw -L/usr/local/lib
$ ./main.exe
Code works