我有一个具有以下结构的示例。
├── CMakeLists.txt
├── ext
│ └── pybind11
└── main.cpp
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(notworking)
add_subdirectory(ext/pybind11)
add_executable(notworking
main.cpp)
target_link_libraries(notworking PRIVATE python3.6m)
target_link_libraries(notworking PRIVATE pybind11)
主文件
#include <pybind11/pybind11.h>
namespace py = pybind11;
int main() { py::object decimal = py::module::import("decimal"); }
现在在运行时
╰─ ./notworking
[1] 14879 segmentation fault (core dumped) ./notworking
为了让这个模块在这里正确加载,我缺少什么?我已经搜索了文档,特别是构建系统部分,但结果是空的。
在 C++ 的 pybind11 中使用其他包装器时,我似乎也是这种情况。