我試圖總結包含只有兩個.C源文件一個非常簡單的C庫:dbc2dbf.c和blast.c如何正確包裝一個C庫與Python CFFI
我做以下(來自文檔):
import os
from cffi import FFI
blastbuilder = FFI()
ffibuilder = FFI()
with open(os.path.join(os.path.dirname(__file__), "c-src/blast.c")) as f:
blastbuilder.set_source("blast", f.read(), libraries=["c"])
with open(os.path.join(os.path.dirname(__file__), "c-src/blast.h")) as f:
blastbuilder.cdef(f.read())
blastbuilder.compile(verbose=True)
with open('c-src/dbc2dbf.c','r') as f:
ffibuilder.set_source("_readdbc",
f.read(),
libraries=["c"])
with open(os.path.join(os.path.dirname(__file__), "c-src/blast.h")) as f:
ffibuilder.cdef(f.read(), override=True)
if __name__ == "__main__":
# ffibuilder.include(blastbuilder)
ffibuilder.compile(verbose=True)
這不太合適。我想我不包括blast.c正確;
任何人都可以幫忙嗎?
不確定爲什麼你需要的''FFI()''兩個實例。這當然不在文檔中... –