我正在尝试将我的程序编译为共享库,以便可以使用ctypes在Python代码中调用。
使用以下命令可以成功编译该库:
g++ -shared -Wl,-soname,mylib -O3 -o mylib.so -fPIC [files] `pkg-config --libs --cflags opencv`
但是,当我尝试使用ctypes导入它时
from ctypes import *
mylib = CDLL("/path/to/mylib.so")
print mylib.test() // Expected output: Hello World
我遇到了以下错误:
libdc1394 error: Failed to initialize libdc1394
发生了什么?
/etc/rc.local
中的exit 0
行之前添加ln /dev/null /dev/raw1394
即可。 - lucaferrario