[3rd Party] VTK 9.4 exposes nlohmann::json publicly, causing ODR conflicts
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cmake, cpp
- Domain
- build-system, computer-vision
Research direction
Start by reviewing the VTK 9.4 handling described in vtk_nlohmannjson.h and the linked VTK discussions and merge requests. Reproduce the PCL 1.15.1 integration with an external nlohmann::json configuration, then determine whether the VTK upgrade, external VTK dependency, or a PCL workaround removes the public vtknlohmann conflict.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 4.7k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PointCloudLibrary/pcl
-
kind: bug status: triage
Difficulty 1/5 Under an hour Newbie friendliness 82/100
PointCloudLibrary/pcl#6536 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
PointCloudLibrary/pcl#6509 · 1 comment ·
Maintainers usually reply within 3 days
-
kind: bug status: triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PointCloudLibrary/pcl#6537 ·
Maintainers usually reply within 3 days
-
[cmake] QHULL/FLANN dll missing when linking single modulePossibly taken @SIDDARTHAREDDY8 claimed this 5 days ago. Openkind: bug module: cmake
Difficulty 3/5 Half a day Newbie friendliness 50/100
PointCloudLibrary/pcl#6522 · 1 comment ·
Maintainers usually reply within 3 days
-
kind: bug status: triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
PointCloudLibrary/pcl#6395 ·
Maintainers usually reply within 3 days
All issues in PointCloudLibrary/pcl
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nextcloud/passman-android#214 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
feature wsl2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/WSL#42306 · 3 comments ·
Maintainers usually reply within 1 day
-
2026.11.0 fails to install on Intel macOS: requirements.txt pins cryptography==50.0.2 for Darwin x86_64May be free again A pull request for this issue was closed without being merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 87/100
esphome/esphome#22892 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
distante/esphome-components#50 · 1 comment ·
Maintainers usually reply within 1 day