如何为python编译一个C / C ++函数 [英] how to compile a C/C++ function for python

查看:142
本文介绍了如何为python编译一个C / C ++函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用cpp编写的源代码,我想编译并在Python中可读。
Python必须给出2个文件名作为输入,并检索矩阵和向量作为输出。
如果我不得不在C / C ++中使用2个字符和2个指针,但我不知道如何编译的C / C ++程序可以看到Python语言。



我希望有人能帮助我。 rel =nofollow> Swig 生成从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.

解决方案

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

这篇关于如何为python编译一个C / C ++函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆