I am trying to get started with this example on: LearnOpenGL - Hello Window
I wanted to locally compile it using a sort of deps/ system so, i am using this cmake setup (publicly available)
project( GLFW-CMake-starter )
find_package( OpenGL REQUIRED )
include_directories( ${OPENGL_INCLUDE_DIRS} )
set( GLFW_BUILD_DOCS OFF CACHE BOOL "GLFW lib only" )
set( GLFW_INSTALL OFF CACHE BOOL "GLFW lib only" )
set( GLAD_GL "" )
add_subdirectory( deps/glfw )
option( GLFW-CMAKE-STARTER-USE-GLFW-GLAD "Use GLAD from GLFW" ON )
if( GLFW-CMAKE-STARTER-USE-GLFW-GLAD )
include_directories("${GLFW_SOURCE_DIR}/deps")
set( GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" )
endif()
if( MSVC )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup" )
endif()
set( GLFW-CMAKE-STARTER-SRC
src/main.cpp
)
add_executable( GLFW-CMake-starter WIN32 ${GLFW-CMAKE-STARTER-SRC} ${GLAD_GL} )
target_link_libraries( GLFW-CMake-starter ${OPENGL_LIBRARIES} glfw )
if( MSVC )
if(${CMAKE_VERSION} VERSION_LESS "3.6.0")
message( "\n\t[ WARNING ]\n\n\tCMake version lower than 3.6.\n\n\t - Please update CMake and rerun; OR\n\t - Manually set 'GLFW-CMake-starter' as StartUp Project in Visual Studio.\n" )
else()
set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT GLFW-CMake-starter )
endif()
endif()
I get (when i include glad/gl.h):
/home/tanshu/Desktop/game-dev/lasthope/deps/glfw/deps/glad/gl.h:31:6: error: #error OpenGL header already included (API: gl), remove previous include!
31 | #error OpenGL header already included (API: gl), remove previous include!
| ^~~~~
/home/tanshu/Desktop/game-dev/lasthope/deps/glfw/deps/glad/gl.h:33: warning: "__gl_h_" redefined
33 | #define __gl_h_ 1
|
In file included from /home/tanshu/Desktop/game-dev/lasthope/deps/glfw/include/GLFW/glfw3.h:241,
from /home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:1:
/usr/include/GL/gl.h:28: note: this is the location of the previous definition
28 | #define __gl_h_
|
In file included from /home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:2:
/home/tanshu/Desktop/game-dev/lasthope/deps/glfw/deps/glad/gl.h:641: warning: "GL_INVALID_INDEX" redefined
641 | #define GL_INVALID_INDEX 0xFFFFFFFF
|
In file included from /usr/include/GL/gl.h:2050,
from /home/tanshu/Desktop/game-dev/lasthope/deps/glfw/include/GLFW/glfw3.h:241,
from /home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:1:
/usr/include/GL/glext.h:1355: note: this is the location of the previous definition
1355 | #define GL_INVALID_INDEX 0xFFFFFFFFu
|
In file included from /home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:2:
/home/tanshu/Desktop/game-dev/lasthope/deps/glfw/deps/glad/gl.h:1340: warning: "GL_TIMEOUT_IGNORED" redefined
1340 | #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
|
In file included from /usr/include/GL/gl.h:2050,
from /home/tanshu/Desktop/game-dev/lasthope/deps/glfw/include/GLFW/glfw3.h:241,
from /home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:1:
/usr/include/GL/glext.h:1430: note: this is the location of the previous definition
1430 | #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull```
(when i dont include glad/gl.h):
```/home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:18:28: error: ‘GLADloadproc’ was not declared in this scope
18 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
| ^~~~~~~~~~~~
/home/tanshu/Desktop/game-dev/lasthope/src/main.cpp:18:10: error: ‘gladLoadGLLoader’ was not declared in this scope
18 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
Assistance would be much appreciated, thanks
System:
Kernel: 5.15.0-76-generic x86_64 bits: 64 compiler: gcc v: 11.3.0 Desktop: Cinnamon 5.8.4
tk: GTK 3.24.33 wm: muffin dm: LightDM Distro: Linux Mint 21.2 Victoria base: Ubuntu 22.04 jammy