[3rd Party] VTK 9.4 exposes nlohmann::json publicly, causing ODR conflicts
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cmake, cpp
调研方向
首先查看 vtk_nlohmannjson.h 中描述的 VTK 9.4 处理方式,以及链接的 VTK 讨论和 merge request。使用外部 nlohmann::json 配置复现 PCL 1.15.1 的集成,然后确定 VTK 升级、外部 VTK 依赖或 PCL workaround 是否能消除公开的 vtknlohmann 冲突。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When using PCL linked with VTK 9.4, the internal nlohmann::json bundled inside VTK (renamed to vtknlohmann in vtk_nlohmannjson.h) is exposed publicly. This causes conflicts when a project also uses a separate nlohmann::json configuration: the compiler raises One Definition Rule (ODR) conflicts for any functions that use the project’s own nlohmann::json. Moreover, the compiler does not understand the nlohmann::json and kind of forces me to use vtknlohmann::json, which is the internal VTK json.
Context
I was trying to add PCL to my project for point cloud visualization and encountered this bug. PCL installation itself works flawlessly (except for a warning “PATH is too long to be changed,” which I resolved manually).
I am on Windows 11 using Visual Studio 2022.
To Reproduce
- Install, configure, and link nlohmann::json for your project using CMake (I used FetchContent).
- Install PCL (latest release) and configure CMake to link it to your project.
- Write a function using your own nlohmann::json.
- Write a function that uses VTK (the error appeared when I tried to visualize a point cloud).
Screenshots / Code snippets
Screenshot showing the conflict:
Code snippet indicated by the last error:
Note the error at line 62: the compiler expects vtknlohmann instead of nlohmann because VTK redefines it here:
My Environment
- OS: Windows 11 24H2
- Compiler: MSVC 19.44.35217.0
- PCL Version: 1.15.1
Possible Solutions
Here are some resources about this problem:
- https://discourse.vtk.org/t/conflict-with-vtknlohmann-and-nlohmann/14977
- https://discourse.vtk.org/t/nlohmann-json-and-vtks-public-api/15131
- https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11854#05ea885e5469ae3672a62ca185b451ca5aaaa3a0
- https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11163
This problem appears to be resolved in VTK 9.5. Possible approaches:
- Upgrade the VTK version distributed with PCL to 9.5.
- Rebuild VTK with
VTK_MODULE_USE_EXTERNAL_VTK_nlohmannjson=ON. - Apply a workaround in PCL to avoid conflicts while keeping VTK 9.4.
Additional Information
This is my first issue submission ever, so sorry if it’s not perfect.
I tried exploring the source code to propose a fix, but haven’t made progress yet. I plan to investigate further.
- 主要语言
- C++
- 星标
- 11.2k
- 派生
- 4.7k
- 平均合并
- 6 天 13 小时
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PointCloudLibrary/pcl 的其他 Issue
-
kind: bug status: triage
难度 1/5 1 小时以内 新手友好度 82/100
PointCloudLibrary/pcl#6536 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
PointCloudLibrary/pcl#6509 · 1 条评论 ·
维护者通常 3 天内回复
-
kind: bug status: triage
难度 4/5 3-5 天 新手友好度 48/100
PointCloudLibrary/pcl#6537 ·
维护者通常 3 天内回复
-
[cmake] QHULL/FLANN dll missing when linking single module可能已有人在做 @SIDDARTHAREDDY8 于 6 天前认领。 未关闭kind: bug module: cmake
难度 3/5 半天 新手友好度 50/100
PointCloudLibrary/pcl#6522 · 1 条评论 ·
维护者通常 3 天内回复
-
kind: bug status: triage
难度 4/5 3-5 天 新手友好度 35/100
PointCloudLibrary/pcl#6395 ·
维护者通常 3 天内回复
查看 PointCloudLibrary/pcl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
HarperFast/rocksdb-js#1131 ·
维护者通常 1 天内回复
-
area/daemon bug good first issue platform/linux priority/p2
难度 2/5 1-3 小时 新手友好度 72/100
ToshiNamura/Deimos#5 ·
-
needs-format
难度 2/5 1-3 小时 新手友好度 82/100
Niko1221/Strata#6251 · 1 条评论 ·
维护者通常 5 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
metasequoiaime/msime#11666 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
patrick-hudson/put.gd-desktop#1679 · 1 条评论 ·
维护者通常 1 天内回复