-
Notifications
You must be signed in to change notification settings - Fork 39
Description
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:
#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