首页 > 编程语言 > 详细

Python 调用 C 语言 so

时间:2014-12-29 18:14:21      阅读:326      评论:0      收藏:0      [点我收藏+]
$ gcc -shared -Wl,-soname,testlib -o testlib.so -fPIC testlib.c
如果在Mac OS X ,则
$ gcc -shared -Wl,-install_name,testlib.so -o testlib.so -fPIC testlib.c

 

 

import ctypes


s0 = ‘hello,www.cricode.com‘

s1 = ctypes.create_string_buffer(s0)

testlib1 = ctypes.CDLL(‘./testlib1.so‘)

testlib1.reverse(s0)

print ‘s0 is: ‘,s0

print ‘s1 is: ‘,s1.value

 

引用:http://www.cricode.com/359.html 

 

Python 调用 C 语言 so

原文:http://www.cnblogs.com/li-baibo/p/4192084.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!