You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for providing this build example.
To give some context for my question. I aim to create a pybind11 binding for one C++ function to enable its invocation from Python code. But this function dependes on a third-party library called OpenCASCADE.
I'm building on a windows OS. I have cloned this repository and tried to add a simple function into the main.cpp to test the build. I have added the following lines:
main.cpp:
#include <TopoDS_Shape.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
TopoDS_Shape makeBox(float length, float width, float height){
return BRepPrimAPI_MakeBox(length, width, height).Shape();
}
m.def("make_box", &makeBox, "A function that returns a TopoDS_Shape");
And I have also added these lines into the CmakeLists.txt to take into account the OpenCASCADE dependecy:
CmakeLists.txt:
set(OpenCASCADE_DIR "C:/Program Files/OCCT/opencascade-install/cmake")
# OpenCascade
find_package(OpenCASCADE)
# Configure C++ compiler's includes dir
include_directories(SYSTEM ${OpenCASCADE_INCLUDE_DIR})
# Add linker options
foreach(LIB ${OpenCASCADE_LIBRARIES})
# TODO: add only optimized build in production
#target_link_libraries(_core PUBLIC debug ${OpenCASCADE_LIBRARY_DIR}d/${LIB}.lib)
target_link_libraries(_core PUBLIC optimized ${OpenCASCADE_LIBRARY_DIR}/${LIB}.lib)
endforeach(LIB)
set_property(TARGET _core PROPERTY VS_DEBUGGER_ENVIRONMENT "PATH=$<$<CONFIG:DEBUG>:${OpenCASCADE_BINARY_DIR}d>$<$<NOT:$<CONFIG:DEBUG>>:${OpenCASCADE_BINARY_DIR}>;%PATH%")
When I run pip install ./scikit_build_example I have a successful installation, but then when I try to import scikit_build_example I get the following error:
module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed while importing _core: The specified module could not be found.
Searching about this error I've found some people saying that to solve I could use the following code:
import os
os.add_dll_directory()
So I've tried referencing my opencascade installation folder, that on my machine is on the path: "C:/Program Files/OCCT/opencascade-install/win64/vc14/bin"
It worked. I would like to know if is there some way to specify this path in the moment of the build. If it should be specified in the CmakeLists.txt or in other file like pyproject.toml.
Any insights or examples on this matter would be highly appreciated!
Thank you very much for the attention
The text was updated successfully, but these errors were encountered:
I have encountered the same issue. The dynamic libraries fail to load because the pip install ./foo command only copies the _core.xxxxxx.pyd file to the site-packages/foo/ directory, without also copying the required dynamic libraries to the 'lib' directory. I solved this issue by creating a symbolic link for the dynamic library that foo depends on, within the Python dependency library. This approach is not elegant, I hope someone can give me some hints.
Hello, everyone
First of all, thank you for providing this build example.
To give some context for my question. I aim to create a pybind11 binding for one C++ function to enable its invocation from Python code. But this function dependes on a third-party library called OpenCASCADE.
I'm building on a windows OS. I have cloned this repository and tried to add a simple function into the main.cpp to test the build. I have added the following lines:
main.cpp:
And I have also added these lines into the CmakeLists.txt to take into account the OpenCASCADE dependecy:
CmakeLists.txt:
When I run
pip install ./scikit_build_example
I have a successful installation, but then when I try to import scikit_build_example I get the following error:Searching about this error I've found some people saying that to solve I could use the following code:
So I've tried referencing my opencascade installation folder, that on my machine is on the path: "C:/Program Files/OCCT/opencascade-install/win64/vc14/bin"
It worked. I would like to know if is there some way to specify this path in the moment of the build. If it should be specified in the CmakeLists.txt or in other file like pyproject.toml.
Any insights or examples on this matter would be highly appreciated!
Thank you very much for the attention
The text was updated successfully, but these errors were encountered: