perlのxsと比較すると、かなり簡単な気がします
step1 - Cソースを作成
$ vi HelloCtypes.c
#include <stdio.h>
void hello_ctypes() {
printf("HELLO CTYPES\n");
}
step2 - Cソースをコンパイル
$ gcc -shared -fPIC -o HelloCtypes.so HelloCtypes.c
step3 - python scriptを作成
$ vi call_ctypes.py
from ctypes import *
def main():
so = cdll.LoadLibrary("./HelloCtypes.so")
so.hello_ctypes()
if __name__ == "__main__":
main()
step4 - 実行
$ python ./call_ctypes.py HELLO CTYPES