Python嵌入c中时应该链接的库有哪些

开发 后端
在计算机的实际的操作中库这一词是否耳熟能详?以下的文章就是对把Python嵌入c中时应该链接的库的相关介绍,希望你会从中得到自己想要的东西。

如果你对把Python嵌入c中时应该链接时有哪些库可以对其进行连接时,你就可以点击我们的文章进行观看,对把Python嵌入c中时应该链接的库有所了解,以下是文章的具体介绍,望你会有所啊后或。

  1. //------------------------------------------   
  2. //cppobj.h   
  3. //   
  4. #include <iostream>   
  5. using namespace std;   
  6. class cppobj {   
  7. private :   
  8. string s;   
  9. public :   
  10. cppobj(string a): s(a) {};   
  11. string show() {return s;}   
  12. };   
  13. //-----------------------------------------   
  14. //------------------------------------------   
  15. //cppobj.i   
  16. %module cppobj   
  17. %include "std_string.i"   
  18. %{   
  19. #include "cppobj.h"   
  20. %}   
  21. %include "cppobj.h"   
  22. //------------------------------------------   
  23. //------------------------------------------   
  24. // Makefile   
  25. _cppobj.so: cppobj_wrap.o   
  26. g++ -o $@ $< -shared -fpic -lpython24   
  27. cppobj_wrap.cxx: cppobj.i cppobj.h   
  28. swig -c++ -python cppobj.i   
  29. cppobj_wrap.o: cppobj.h cppobj_wrap.cxx   
  30. g++ -c cppobj_wrap.cxx -fpic -IC:/Python24/include   
  31. clean:   
  32. rm -rf cppobj_wrap.cxx _cppobj.so *.o cppobj.py cppobj.pyc   
  33. //------------------------------------------   

把Python嵌入c中时应该链接库的相关代码的前部分介绍做完之后还要

  1. $ mv _cppobj.so _cppobj.pyd  

然后就可以

  1. >>> from cppobj import cppobj   
  2. >>> c = cppobj('Hello')   
  3. >>> c.show()   
  4. 'Hello'  

很久以前记的笔记,希望能帮上忙Top以上就是对把Python嵌入c中时应该链接库的相关代码的介绍,望你会有所收获。

【编辑推荐】

  1. 把Python嵌入C/C++元组操作的具体以应用方案介绍
  2. Python嵌入C/C++(较低层次嵌入)时所需用到的函数
  3. Python嵌入C/C++会产生的强大功能的介绍
  4. Python嵌入C++来弥补C++本身不足之处的方案介绍
  5. 用Python连接PostgreSQL数据库所需版本的介绍
责任编辑:佚名 来源: 博客园
相关推荐

2010-06-09 10:20:56

链接MySQL数据库

2010-03-26 10:19:31

Python嵌入CC++

2011-05-18 17:15:45

2010-03-24 12:45:00

Python 嵌入

2010-03-16 15:38:57

Python串口

2010-03-16 15:38:57

Python串口

2011-05-26 16:52:33

2021-06-18 08:15:37

Linux软链接硬链接

2010-04-21 14:11:56

Oracle数据库

2020-02-11 09:41:02

Go语言程序员文章

2020-02-05 16:55:11

Go语言程序员文章

2020-06-11 08:39:55

数据库存储技术

2017-07-26 12:31:19

Python核心库数据科学

2020-03-03 09:28:30

Python内存开发

2017-07-25 09:53:37

Python机器学习

2024-01-11 12:13:29

云监控网络云计算

2010-08-09 13:08:45

DB2数据库

2010-06-12 10:49:12

2010-05-07 17:56:10

Oracle数据库安全

2022-04-18 12:29:18

C++
点赞
收藏

51CTO技术栈公众号