Important: I didn't use Visual Code (much info in Internet about OpenGL setting up is related to this IDE) (I use VSCode).
As I got, there is OpenGL realization (GLFW) and OpenGL loader, that load OpenGL on specific platform (GLEW):
#define GLEW_STATIC
#include <GL/glew.h>
#define GLFW_DLL
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
return 0;
}
I completely stuck on error:
g++ src/main.cpp -lglfw3dll -I.\include\ -L.\lib\ -g -std=c++17 -lopengl32 -lgdi32
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\User\AppData\Local\Temp\ccQkrCsr.o: in function 'main':
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\User\Code\OpenGL/src/main.cpp:13: undefined reference to '_imp__glfwWindowHint'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\User\Code\OpenGL/src/main.cpp:15: undefined reference to '_imp__glfwWindowHint'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\User\Code\OpenGL/src/main.cpp:17: undefined reference to '_imp__glfwWindowHint'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\User\Code\OpenGL/src/main.cpp:19: undefined reference to '_imp__glfwWindowHint'
collect2.exe: error: ld returned 1 exit status
My project structure:
│ glfw3.dll
│
├───include
│ ├───GL
│ │ eglew.h
│ │ glew.h
│ │ glxew.h
│ │ wglew.h
│ │
│ └───GLFW
│ glfw3.h
│ glfw3native.h
│
├───lib
│ glew32s.lib
│ libglfw3dll.a
│
└───src
main.cpp
Here is the similar question, but it didn't help me.