Skip to content

[g2o] add opengl as dependency #52932

Description

@dalux-mv

Is your feature request related to a problem? Please describe.

g2o picks OpenGL from system install if available.

https://github.com/RainerKuemmerle/g2o/blob/34013227eeba9492946d5e4b6a678c0c79c0b34b/CMakeLists.txt#L165

  1. This forces shared library of g2o to link against OpenGL from system install when available.
  2. Moreover, this causes g2o to always linked against OpenGL even when -DG2O_BUILD_APPS=OFF -DG2O_BUILD_EXAMPLES=OFF

For example,

$ ldd foo_binary
...
	libg2o_types_sim3.so.0.1 => /foo_path/x64-linux-dynamic-release/lib/libg2o_types_sim3.so.0.1 (abz)
	libg2o_types_sba.so.0.1 => /foo_path/x64-linux-dynamic-release/lib/libg2o_types_sba.so.0.1 (abe)
	libg2o_types_slam3d.so.0.1 => /foo_path/x64-linux-dynamic-release/lib/libg2o_types_slam3d.so.0.1 (abd)
	libg2o_opengl_helper.so.0.1 => /foo_path/x64-linux-dynamic-release/lib/libg2o_opengl_helper.so.0.1 (abc)
...

$ ldd /foo_path/x64-linux-dynamic-release/lib/libg2o_opengl_helper.so.0.1
        linux-vdso.so.1 (0x0000708db378d000)
        libGLU.so.1 => /foo/lib/libGLU.so.1 (0x0000708db3727000)
        libGLX.so.0 => /foo/lib/libGLX.so.0 (0x0000708db36f3000)
        libOpenGL.so.0 => /foo/lib/libOpenGL.so.0 (0x0000708db36c7000)
...

Proposed solution

"OpenGL" should be dependency for g2o (similar to "ceres", "eigen3", "lapack", "suitesparse-cholmod", "suitesparse-cxsparse")

Describe alternatives you've considered

Copied the content of port to custom overlay and set flag that disables OpenGL in portfile.cmake

vcpkg_cmake_configure(
...
        -DG2O_USE_OPENGL=OFF
...
)

Additional context

System information

OS : Ubuntu 24.04 6.17.0-40-generic
VS Code : 1.128.1
Docker version : 28.3.3
vcpkg version : 2026-05-27-d5b6777d666efc1a7f491babfcdab37794c1ae3e
g2o version : 2024-12-28#0

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:port-featureThe issue is with a library, which is requesting new capabilities that didn’t exist

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions