PointCloudLibrary / PointCloudLibrary/pcl
[features] ImportError: DLL load failed with pybind11 and PCL
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 4.7k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 6
Description
I'm using pybind11 to create a Python wrapper for a small C++ class.
I'm getting the following error when importing the DLL (running python -v to show Traceback):
>>> from a_py import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
File "<frozen importlib._bootstrap>", line 556, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1101, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed while importing a_py: The specified module could not be found.
The class has just two members - types from the PCL library:
class A
{
pcl::NormalEstimation< pcl::PointXYZ, pcl::Normal> normalEstimation_;
pcl::PointCloud<pcl::Normal>::Ptr normals_;
};
If I remove the first member I can successfully import the module from the DLL.
This is the pybind11 code:
namespace py = pybind11;
PYBIND11_MODULE(a_py, m)
{
py::class_<A>(m, "A");
}
PCL is found using CMake: find_package(PCL REQUIRED)
This happens on both Windows and Linux with the latest PCL (1.10) and older versions too.
(Adding #define PCL_NO_PRECOMPILE before the #includes does not help.)
[also posted on SO]
Your Environment (please complete the following information):
- OS: Windows 10 (but similar issues on Linux)
- Compiler: MSVC 2019
- PCL Version1.10.0
Possible Solution
Based on a SO suggestion I ran the Dependencies app on both DLLs (with and without the offending line).
The main difference was that the offending DLL depends on c:\Program Files\PCL 1.10.0\bin\pcl_common.dll. Strangely enough, it seems to only rely on one function: void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const * __ptr64,...).
AFAICT, PCL is mostly header only, and somewhere within the guts of pcl::NormalEstimation there is a logging function which is not header-only and needs linking. Is there a way to prevent this call?
BTW, the DLL is in the DLL paths (and as can be seen in the screenshot - available) so it is still unclear why Python fails to load the module.

Additional context
Add any other context about the problem here.
Contributor 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.
Research direction
Start with the C++ class A and the pybind11 module a_py, comparing imports with and without pcl::NormalEstimation. Review the CMake find_package(PCL REQUIRED) setup and inspect the generated DLL dependencies, especially pcl_common.dll, using the Dependencies app. Done means the module imports successfully on the reported Windows and Linux setups without the missing-DLL error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100