I am trying to run a single program using OpenGL:
#include "glad/glad.h"
#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_OPENGL_FORWARD_COMPAT, GL_TRUE);
return 0;
}
But if I try to compile it with this Makefile, I get the following errors:
g++ -Wall -Iinclude -lglut -lGL -lGLU -lGLEW -lm -L/usr/local/lib -o opengl src/main.cpp
/tmp/ccc3n0wR.o: In function `main':
main.cpp:(.text+0x5): undefined reference to `glfwInit'
main.cpp:(.text+0x14): undefined reference to `glfwWindowHint'
main.cpp:(.text+0x23): undefined reference to `glfwWindowHint'
main.cpp:(.text+0x32): undefined reference to `glfwWindowHint'
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'opengl' failed
make: *** [opengl] Error 1
I'm also using GLAD.
Result of glxinfo | grep version
:
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.6.0 NVIDIA 440.100
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 440.100
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 440.100
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
GL_EXT_shader_group_vote, GL_EXT_shader_implicit_conversions,
Additional information: I have compiled glfw3
my self, and I am trying to follow this tutorial to learn OpenGL basics. Instead of using Microsoft Visual Studio 2019
, I am using Visual Studio Code
.
All the code I'm using can be found in this repository.