$
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