HasDW
HasDW

Reputation: 35

Segmentation fault in Pybind11 when trying to bridge yices library in usr/local/include

I am trying to bridge my c++ code with python using pybind11. I have example.cpp file and it has an include to yices.h. yices.h is in usr/local/includes folder.

#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");
 }

When I try the test.py I am getting a segmentation error. How to link yices.h using pybind11?

from example import add

Here is the cmake file

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)

Upvotes: 0

Views: 975

Answers (1)

Piotr Barejko
Piotr Barejko

Reputation: 648

You forgot to link it with gmp and yices:

target_link_libraries(example PUBLIC yices gmp)

Upvotes: 1

Related Questions