如何编译 C/C++ python 的函数

发布于 2025-01-06 21:28:37 字数 185 浏览 1 评论 0原文

我有一个用 cpp 编写的源代码,我想对其进行编译并在 Python 中可读。 Python 必须提供 2 个文件名作为输入,并检索一个矩阵和一个向量作为输出。 如果我必须在 C/C++ 中执行此操作,我会使用 2 个字符和 2 个指针,但我不知道如何为 Python 语言查看已编译的 C/C++ 程序。

我希望有人能帮助我。 非常感谢。

I have a source code written in cpp that I want to compile and be readable in Python.
Python must give 2 filenames as input and retrieve a matrix and a vector as output.
If I had to do it in C/C++ I'd use 2 chars and 2 pointers but I don't know how a compiled C/C++ program can be seen for Python language.

I hope that someone can help me.
Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你げ笑在眉眼 2025-01-13 21:28:37

尝试使用 Swig 生成从 Python 调用 C/C++ 代码所需的粘合代码。这比自己编写代码更容易。

Try using Swig to generate the glue code necessary to call C/C++ code from Python. It's easier than writing the code yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文