'Compilation issues with a simple ImGui(GLFW+OpenGL3) program on Linux

I am getting the following error while compiling a simple imgui+glfw+opengl3 program on GCC 11.2.0 on Pop!_OS (Ubuntu):

[build] In file included from ../external/imgui/backends/imgui_impl_opengl3.cpp:142:
[build] ../external/imgui/backends/imgui_impl_opengl3_loader.h:446:9: error: 
‘PFNGLBINDTEXTUREPROC’ does not name a type; did you mean ‘PFNGLBINDTEXTURESPROC’?
[build]   446 |         PFNGLBINDTEXTUREPROC             BindTexture;
[build]       |         ^~~~~~~~~~~~~~~~~~~~
[build]       |         PFNGLBINDTEXTURESPROC
[build] compilation terminated due to -Wfatal-errors.

This is how the problematic definitions from imgui/backends/imgui_impl_opengl3.cpp look in an IDE with syntax highlighting:

enter image description here

My opengl version:

> $ glxinfo | grep "OpenGL version"                                                                                                                                               
OpenGL version string: 4.6.0 NVIDIA 470.86

I am using the following Cmake setup:

# imgui
include_directories("external/imgui")
include_directories("external/imgui/backends")
file(GLOB SRC_IMGUI external/imgui/*.cpp)
set(SRC_IMGUI_BACKEND external/imgui/backends/imgui_impl_glfw.cpp external/imgui/backends/imgui_impl_opengl3.cpp)
target_sources(shenanigans PRIVATE ${SRC_IMGUI} ${SRC_IMGUI_BACKEND})

# glfw
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(external/glfw)
target_link_libraries(shenanigans PRIVATE glfw)

I include the relevant headers in a precompiled header like so:

#pragma once
#include <span>
#include <type_traits>
#include <concepts>
// ... and other STL headers

#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <GLFW/glfw3.h>

Any ideas where the issue might be?



Solution 1:[1]

switch the order of <imgui_impl_glfw.h> and <imgui_impl_opengl3.h>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 masterX