stevenlovegrove / Pangolin

Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.
MIT License
2.33k stars 844 forks source link

Pangolin forgets HAVE_GLEW when installed #803

Open alex-fu27 opened 1 year ago

alex-fu27 commented 1 year ago

Steps: I cloned the repo, built Pangolin from source. GLEW is found correctly,

$ grep 'GLEW' build/CMakeCache.txt 
GLEW_INCLUDE_DIR:PATH=/usr/include
//The GLEW library
GLEW_LIBRARY:FILEPATH=/usr/lib/libGLEW.so
pango_opengl_LIB_DEPENDS:STATIC=general;pango_core;general;pango_image;general;/usr/lib/libGLEW.so;general;/usr/lib/libOpenGL.so;general;/usr/lib/libGLX.so;general;/usr/lib/libGLU.so;

I built with ninja -v and -DHAVE_GLEW is correctly passed to the compiler.

I then created the following test.cpp:

#include <pangolin/pangolin.h>

and tried to compile with gcc -Wfatal-errors -Idest/usr/local/include test.cpp:

In file included from dest/usr/local/include/pangolin/gl/gl.h:324,
                 from dest/usr/local/include/pangolin/handler/handler.h:31,
                 from dest/usr/local/include/pangolin/display/widgets.h:32,
                 from dest/usr/local/include/pangolin/pangolin.h:40,
                 from test.cpp:1:
dest/usr/local/include/pangolin/gl/gl.hpp: In member function 'void pangolin::GlTexture::CopyFrom(const pangolin::GlTexture&)':
dest/usr/local/include/pangolin/gl/gl.hpp:348:5: error: 'glCopyImageSubDataNV' was not declared in this scope
  348 |     glCopyImageSubDataNV(tex.tid, GL_TEXTURE_2D, 0, 0, 0, 0,
      |     ^~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.

This is because nothing sets HAVE_GLEW in that case and in glplatform.h:

#ifdef HAVE_GLEW
    #include <GL/glew.h>
#endif

is conditional.

For most other users it might work because

The first two can be used as a workaround.

stevenlovegrove commented 1 year ago

Sorry about that - I have a cmake-centric workflow and this (and many other) defines are configured as part of the CMake export interface (output here https://github.com/stevenlovegrove/Pangolin/blob/master/cmake/PangolinConfig.cmake.in#L6).

Since the library is split into many components, it saves me from having a seperate config.h.in file for each component, but I see it would cause problems for non-cmake users. I'm not sure what the most elegant solution is here. A workaround is to use CMake, but that won't suit everyone.

xlb8 commented 1 year ago

Sorry about that - I have a cmake-centric workflow and this (and many other) defines are configured as part of the CMake export interface (output here https://github.com/stevenlovegrove/Pangolin/blob/master/cmake/PangolinConfig.cmake.in#L6).

Since the library is split into many components, it saves me from having a seperate config.h.in file for each component, but I see it would cause problems for non-cmake users. I'm not sure what the most elegant solution is here. A workaround is to use CMake, but that won't suit everyone.

hi,steven .thanks to your nice code. and i use cmake 3.16 and the latest branch of pangolin ,it appears the kind of error "undefined gl***" above.hope you can check this problem. the HAVE_GLEW defined in PangolinTargets.cmake seems not work .i defined it in my CMakeList.txt of my program to solve this tempararily..