I got new results, I found this problem comes from using capnp by python 
and c++ in the same project while Interface has been declared within .capnp 
which are used in c++ project.
 for example: 
// main.cpp
#include <pybind11/embed.h>
namespace py = pybind11;

int main() {
    py::scoped_interpreter guard{};

    py::exec(R"(
        message = "Start example"
        print(message)
        import capnp
        import address_capnp
        message = "Import address_capnp done successfully"
        print(message)
    )");
}

# address.capnp
@0x85150b117366d14b;
struct Person {
  id @0 :UInt32;
  name @1 :Text;
  email @2 :Text;
}

interface AddressMethod {
    func @0 (count: Int8 ) -> ();
}

# CMakeLists
cmake_minimum_required(VERSION 3.0)
project(example)

find_package(pybind11 REQUIRED) 
find_package(CapnProto REQUIRED) 
capnp_generate_cpp(addressSources addressHeaders address.capnp)

add_executable(example ${addressSources} main.cpp)
target_link_libraries(example PRIVATE CapnProto::capnp-rpc pybind11::embed)


The above example will work as long as interface AddressMethod in 
address.capnp is removed.
Can anyone help me?



On Tuesday, February 12, 2019 at 7:53:53 PM UTC+3:30, Fakhri Sajadi wrote:
>
> Hi
> I have a python plugin which is called in c++ code(by pybind11). when I 
> use import exp_capnp in the plugin, the c++ codes crashed (Segmentation 
> fault).
> 1. Does anyone have a solution?
> 2. How can I compile `.capnp` to `.py`?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to