如何解决尝试桥接usr / local / include中的yices库时,Pybind11中出现分段错误
我正在尝试使用pybind11将我的c ++代码与python桥接。我有example.cpp文件,并且它包含到yices.h。 yices.h位于usr / local / includes文件夹中。
#include <pybind11/pybind11.h>
#include "yices.h"
int add(int i,int j) {
yices_init();
return i + j;
}
namespace py = pybind11;
PYBIND11_MODULE(example,m) {
// optional module docstring
m.doc() = "pybind11 example plugin";
// define add function
m.def("add",&add,"A function which adds two numbers");
}
当我尝试test.py时,出现了细分错误。如何使用pybind11链接yices.h?
from example import add
这是cmake文件
cmake_minimum_required(VERSION 2.8.12)
project(example)
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIRS})
add_subdirectory(pybind11)
pybind11_add_module(example example.cpp)
解决方法
您忘记将其与gmp
和yices
链接:
target_link_libraries(example PUBLIC yices gmp)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。