推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
Lighthughjiajin
V2EX  ›  Python

Python2 调用 so 文件时,如何传递 C++ std::string& json 和 int* 类型 的参数

  •  
  •   Lighthughjiajin · Dec 20, 2022 · 4355 views
    This topic created in 1439 days ago, the information mentioned may be changed or developed.

    Python 调用 C++ 编译好的 .so 文件,如何传递 C++ 里声明的 std::string& json 和 int* 类型的参数。

    8 replies  •  2022-12-22 17:18:49 +08:00
    leonshaw
    leonshaw
    Dec 20, 2022 via Android
    1
    接口用 C 封装
    Lighthughjiajin
    Lighthughjiajin
    OP
    Dec 20, 2022
    2
    SO 文件是别人提供的,不是我自己写的 。
    ysc3839
    ysc3839
    Dec 20, 2022 via Android
    3
    @Lighthughjiajin 你还可以写一个 so 再封装一些
    ysc3839
    ysc3839
    Dec 20, 2022 via Android
    4
    @ysc3839 再封装一下
    junmoxiao
    junmoxiao
    Dec 20, 2022
    5
    别说用 py 调 c++写的动态库了,你用不同编译器版本的 c++调 c++写的动态库都可能出问题。因为在不同的版本,标准库组件的实现、内存布局可能发生了改变。
    接口最好还是用 c
    elechi
    elechi
    Dec 21, 2022
    6
    C++ 相互之间调用都不推荐用 std 库的类型,因为不同版本的 std 实现都是有差异的。。。
    NoAnyLove
    NoAnyLove
    Dec 22, 2022
    7
    没有 extern "C"吗?要不试试 cython 或者 cppyy ?
    newmlp
    newmlp
    Dec 22, 2022
    8
    建议直接 char*,传对象是不可能的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1910 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:36 · PVG 16:36 · LAX 00:36 · JFK 03:36
    ♥ Do have faith in what you're doing.