Linux上简单ImGui(GLFW+OpenGL3)程序的编译问题

5t7ly7z5  于 2022-11-04  发布在  Linux
关注(0)|答案(1)|浏览(327)

我在Pop!_OS(Ubuntu)上的GCC 11.2.0上编译一个简单的imgui+glfw+ opengl 3程序时遇到以下错误:

[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.

下面是imgui/backends/imgui_impl_opengl3.cpp中有问题的定义在IDE中的外观,语法突出显示:

我的opengl版本:

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

我正在使用以下Cmake设置:


# 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)

我在预编译头文件中包含了相关的头文件,如下所示:


# 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>

你知道问题出在哪里吗?

wgeznvg7

wgeznvg71#

交换和的顺序<imgui_impl_glfw.h><imgui_impl_opengl3.h>

相关问题