使用C ++中的Python库 [英] Use Python library from C++

查看:71
本文介绍了使用C ++中的Python库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的C ++程序中使用Python Libray。

Python Libray不是GUI。如何混合C ++和

Python?


一种方法是将PY库作为一个独立的进程运行。

另一种方式是作为C ++线程开始PY。

第三种方式是将Python引擎作为C ++的一部分运行。

哪种方式更好?


无意访问所有Python的代码,只能访问模块中的
访问API。

I want to use the Python Libray from my C++ program.
The Python Libray is no GUI. How can I mix C++ and
Python?

One way is to run PY library as an independent process.
Another way is to start PY as a C++ thread.
The third way is to run Python engine as part of the C++.
Which way is better?

No intention to access all the Python''s code but only
access APIs of a module.

推荐答案

Chang LI写道:
Chang LI wrote:
我想从我的C ++程序中使用Python Libray。
Python Libray不是GUI。我如何混合使用C ++和Python?

一种方法是将PY库作为一个独立的进程运行。
另一种方法是将PY作为C ++线程启动。
第三种方法是将Python引擎作为C ++的一部分运行。
哪种方式更好?

无意访问所有Python的代码但只能访问
模块的API。
I want to use the Python Libray from my C++ program.
The Python Libray is no GUI. How can I mix C++ and
Python?

One way is to run PY library as an independent process.
Another way is to start PY as a C++ thread.
The third way is to run Python engine as part of the C++.
Which way is better?

No intention to access all the Python''s code but only
access APIs of a module.




尝试Elmer。

http://elmer.sf.net

-

Robert Kern
< a href =mailto:rk *** @ ucsd.edu> rk *** @ ucsd.edu


在草地狱的地方增长很高

梦想的坟墓是否已经死亡。

- Richard Harter



Try Elmer.

http://elmer.sf.net

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter




Chang LI写道:

Chang LI wrote:
我想从我的C ++程序中使用Python Libray。
Python Libray不是GUI。我如何混合使用C ++和Python?

一种方法是将PY库作为一个独立的进程运行。
另一种方法是将PY作为C ++线程启动。
第三种方法是将Python引擎作为C ++的一部分运行。
哪种方式更好?

无意访问所有Python的代码但只能访问
模块的API。
I want to use the Python Libray from my C++ program.
The Python Libray is no GUI. How can I mix C++ and
Python?

One way is to run PY library as an independent process.
Another way is to start PY as a C++ thread.
The third way is to run Python engine as part of the C++.
Which way is better?

No intention to access all the Python''s code but only
access APIs of a module.




尝试使用boost.python和SWIG?

(boost.sourceforge.net,swig.sourceforge.net)


两者都提供C / C ++和python之间的接口

如果你想在python下使用gui,你也可以尝试wxpython或pygtk


zhao写道:
zhao wrote:
尝试使用boost.python和SWIG?
(boost.sourceforge.net,swig.sourceforge.net )

如果你想在python下使用gui,你也可以尝试wxpython或pygtk
Try boost.python and SWIG?
(boost.sourceforge.net, swig.sourceforge.net)

Both provide a interface between C/C++ and python
if you want gui under python, you also can try wxpython or pygtk




我认为SWIG将C / C ++库移植到Perl,Python,Rub y,Tcl等?

你如何使用它将Python移植到C / C ++中?


我认为你在寻找的是指令关于如何在你的C / C ++应用程序中嵌入Python




I thought SWIG ported C/C++ libraries to Perl, Python, Ruby, Tcl, etc?
How would you use it to port Python into C/C++?

I think what you''re looking for is instruction on how to embed Python in
your C/C++ application.


这篇关于使用C ++中的Python库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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