Hi Fakhri,

Is it possible that your pycapnp plugin is compiled against a different
version of libcapnp than the one you are using in C++? If so, this could
certainly cause conflicts that would lead to crashes. Unfortunately,
libcapnp is not ABI-compatible between versions as C++ makes ABI
compatibility difficult, so it's important that all parts of your program
that use libcapnp be compiled against exactly the same version.

-Kenton

On Mon, Feb 25, 2019 at 4:53 AM Fakhri Sajadi <[email protected]> wrote:

> 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.
>

-- 
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