Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how imgui_impl_OpenGL3.cpp can introduce gl3w.h #3860

Closed
Corezcy opened this issue Mar 2, 2021 · 5 comments
Closed

how imgui_impl_OpenGL3.cpp can introduce gl3w.h #3860

Corezcy opened this issue Mar 2, 2021 · 5 comments

Comments

@Corezcy
Copy link

Corezcy commented Mar 2, 2021

Version/Branch of Dear ImGui:

Version: 1.81
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_OpenGL3.cpp + imgui_impl_glfw.cpp _
Compiler: bazel VScode
Operating System: Ubuntu 18.04.5 LTS

My Issue/Question:

Someting like #3507, when I try to use imgui_impl_OpenGL3.cpp to introduce gl3w.h and gl3w.c, imgui_impl_OpenGL3.cpp always link to GL/glew, how to fix it ?
Code
here is code I package imgui

load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "imgui",
    srcs = [
        "GL/gl3w.c",
        "imgui.cpp",
        "imgui_demo.cpp",
        "imgui_draw.cpp",
        "imgui_impl_glfw.cpp",
        "imgui_impl_opengl3.cpp",
        "imgui_stdlib.cpp",
        "imgui_tables.cpp",
        "imgui_widgets.cpp",
    ],
    hdrs = [
        "GL/gl3w.h",
        "GL/glcorearb.h",
        "imconfig.h",
        "imgui.h",
        "imgui_impl_glfw.h",
        "imgui_impl_opengl3.h",
        "imgui_internal.h",
        "imgui_stdlib.h",
        "imstb_rectpack.h",
        "imstb_textedit.h",
        "imstb_truetype.h",
    ],
    includes = [
        ".",
        "GL/",
    ],
    linkopts = [
        "-ldl",
        "-lm",
        "-lGL",
        "-lGLEW",
        "-lGLU",
        "-lX11",
        "-lXi",
        "-lXrandr",
        "-lXxf86vm",
        "-lXinerama",
        "-lXcursor",
    ],
    deps = ["@glfw"],
)

here is the structure of my code, which imgui belongs

.
├── BUILD
├── CMakeLists.txt
├── GL
│   ├── CMakeLists.txt
│   ├── gl3w.c
│   ├── gl3w.h
│   └── glcorearb.h
├── imconfig.h
├── imgui.cpp
├── imgui_demo.cpp
├── imgui_draw.cpp
├── imgui.h
├── imgui_impl_glfw.cpp
├── imgui_impl_glfw.h
├── imgui_impl_opengl3.cpp
├── imgui_impl_opengl3.h
├── imgui_internal.h
├── imgui_stdlib.cpp
├── imgui_stdlib.h
├── imgui_tables.cpp
├── imgui_widgets.cpp
├── imstb_rectpack.h
├── imstb_textedit.h
└── imstb_truetype.h

error report

bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewBlendEquation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewUseProgram'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewUniform1i'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewUniformMatrix4fv'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewBindSampler'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewBindVertexArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewBindBuffer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewBindBuffer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewEnableVertexAttribArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewEnableVertexAttribArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewEnableVertexAttribArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewVertexAttribPointer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewVertexAttribPointer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int): error: undefined reference to '__glewVertexAttribPointer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function CheckShader(unsigned int, char const*): error: undefined reference to '__glewGetShaderiv'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function CheckShader(unsigned int, char const*): error: undefined reference to '__glewGetShaderiv'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function CheckShader(unsigned int, char const*): error: undefined reference to '__glewGetShaderInfoLog'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewActiveTexture'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewGenVertexArrays'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBufferData'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBufferData'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewDrawElementsBaseVertex'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewDeleteVertexArrays'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewUseProgram'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBindSampler'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewActiveTexture'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBindVertexArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBindBuffer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBlendEquationSeparate'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*): error: undefined reference to '__glewBlendFuncSeparate'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewCreateShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewShaderSource'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewCompileShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewCreateShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewShaderSource'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewCompileShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewCreateProgram'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewAttachShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewAttachShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewLinkProgram'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetProgramiv'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetProgramiv'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetUniformLocation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetUniformLocation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetAttribLocation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetAttribLocation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetAttribLocation'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGenBuffers'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGenBuffers'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewBindBuffer'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewBindVertexArray'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_CreateDeviceObjects(): error: undefined reference to '__glewGetProgramInfoLog'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDeleteBuffers'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDeleteBuffers'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDetachShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDetachShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDeleteShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDeleteShader'
bazel-out/k8-opt/bin/third_party/imgui/_objs/imgui/imgui_impl_opengl3.o:imgui_impl_opengl3.cpp:function ImGui_ImplOpenGL3_DestroyDeviceObjects(): error: undefined reference to '__glewDeleteProgram'
@Corezcy
Copy link
Author

Corezcy commented Mar 2, 2021

In version 1.73, it's okay ! I think it's something unchecked with header loader.

@playingoDEERUX
Copy link

playingoDEERUX commented Mar 2, 2021

I have the same issue!! Someone has to fix it please...

@ocornut
Copy link
Owner

ocornut commented Mar 2, 2021

If you read the any of the comments nearby that OpenGL loader mess you would find that:

  • we added autodetection of the OpenGL loader based on available includes
  • you can override it using defines e.g. in your imconfig file: #define IMGUI_IMPL_OPENGL_LOADER_GL3W to force GL3W.

@Corezcy
Copy link
Author

Corezcy commented Mar 2, 2021

If you read the any of the comments nearby that OpenGL loader mess you would find that:

  • we added autodetection of the OpenGL loader based on available includes
  • you can override it using defines e.g. in your imconfig file: #define IMGUI_IMPL_OPENGL_LOADER_GL3W to force GL3W.

I have solve this problem by change the definition order bwteen glew and gl3w.
Thanks anyway ! Let me try your method !

#if __has_include(<GL/glew.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
#elif __has_include(<glad/glad.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
#elif __has_include(<glad/gl.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GLAD2
#elif __has_include(<GL/gl3w.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
#elif __has_include(<glbinding/glbinding.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
#elif __has_include(<glbinding/Binding.h>)
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
#else
#error "Cannot detect OpenGL loader!"
#endif
#else
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
#endif

@Corezcy
Copy link
Author

Corezcy commented Mar 2, 2021

I have the same issue!! Someone has to fix it please...

here is my solution, please check it . Glad if can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants