secretflow / heu

A high-performance homomorphic encryption algorithm library.
https://www.secretflow.org.cn/docs/heu/en/
Apache License 2.0
81 stars 36 forks source link

undefined symbol: PyObject_GenericSetDict #146

Closed wxljpro closed 2 weeks ago

wxljpro commented 1 month ago

Issue Type

Build/Install

HEU Version

最新版本

OS Platform and Distribution

ubuntu20

Python Version

3.10

Compiler Version

gcc11

Current Behavior?

使用C++调用so文件报的错

Standalone code to reproduce the issue

void * handle = dlopen("./heu.so", RTLD_LAZY);
    if(!handle){
            printf("%s\n",dlerror());
    }

Relevant log output

No response

wxljpro commented 1 month ago

so文件使用 /build_wheel_entrypoint.sh编译生成的

shaojian-ant commented 1 month ago

build_wheel_entrypoint.sh 编译生成的 so 文件是给 python 用的。如果 dlopen 的话,可以用 bazel 的 cc_shared_library rule 编译得到 so 文件

wxljpro commented 1 month ago

您好:

  非常感谢您的回复。

   由于我们用的是CMake管理项目,所以对bazel不是很了解。收到您的回复后,就突击学习了一下,虽然略有成效,但是应用到实战上还是无从下手。

   所以再次请教一下,希望您能抽时间解答一下我们的疑惑。

   1.如果我想将项目编译成跟python调用的so的一样功能的so,供C++调用,需要参考哪个文件编写。

   2.还有就是在哪个文件夹下编写BUILD文件。

   不想打扰你呢,但是对bazel实在是不熟悉,希望您看到邮件后,能百忙之中抽出点时间,指点一二。

   再次感谢!

在 2024-07-16 17:33:07,"shaojian-ant" @.***> 写道:

build_wheel_entrypoint.sh 编译生成的 so 文件是给 python 用的。如果 dlopen 的话,可以用 bazel 的 cc_shared_library rule 编译得到 so 文件

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

shaojian-ant commented 1 month ago

您好,我觉得可以直接用 heu 编译出的结果。bazel cc_library 默认同时编译动态库和静态库,在项目目录执行指令 bazel build -c opt heu/library/phe ,目录 ./bazel-bin/heu/library/phe 下就会生成 libphe.so 文件,直接用这个就可以

wxljpro commented 1 month ago

您好:

   非常感谢您的回复。

    我也是编译这个库,不过电脑卡住了。等一会儿编译完成,再告知您结果。

   非常感谢!!!

在 2024-07-17 10:43:28,"shaojian-ant" @.***> 写道:

您好,我觉得可以直接用 heu 编译出的结果。bazel cc_library 默认同时编译动态库和静态库,在项目目录执行指令 bazel build heu/library/phe ,目录 ./bazel-bin/heu/library/phe 下就会生成 libphe.so 文件,直接用这个就可以

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wxljpro commented 1 month ago

您好:

    用您说的方式,生成的so文件,用dlopen的方式加载不到。

    后来我修改一下BUILD.bazel文件

  能够构建成功,不过也加载不到,不知道是不是需要修改一下这个文件的内容

  您有时间帮忙看看这个文件是否需要添加或修改什么内容

  非常感谢!

在 2024-07-17 10:43:28,"shaojian-ant" @.***> 写道:

您好,我觉得可以直接用 heu 编译出的结果。bazel cc_library 默认同时编译动态库和静态库,在项目目录执行指令 bazel build heu/library/phe ,目录 ./bazel-bin/heu/library/phe 下就会生成 libphe.so 文件,直接用这个就可以

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wxljpro commented 1 month ago

您好:

   现在可以了,刚才是我拷贝错误文件了。使用libphe.so这个文件能够加载成功了。就看后面能不能实现调用了。

   谢谢您的指教,非常感谢!!!

在 2024-07-17 10:43:28,"shaojian-ant" @.***> 写道:

您好,我觉得可以直接用 heu 编译出的结果。bazel cc_library 默认同时编译动态库和静态库,在项目目录执行指令 bazel build heu/library/phe ,目录 ./bazel-bin/heu/library/phe 下就会生成 libphe.so 文件,直接用这个就可以

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>