2
我有一个需要GTK的Python扩展模块。编译一个GTK程序通常需要一个TON链接,因为GTK依赖于很多其他库(Glib,Cairo,Pango等)。所以,平时我只是编译使用的pkg-config
输出使用shell扩展(反单引号),如:Distutils和shell扩展
gcc -p-O2 -Wall myprogram.c -o myprogram `pkg-config --cflags gtk+-3.0` `pkg-config --cflag `pkg-config --libs gtk+-3.0`
但由于某些原因,当我在的distutils传递给module.extra_compile_args
参数使用shell扩展,我
module = Extension('mymodule',
sources = ['mymodule.c'])
module.extra_compile_args = ['`pkg-config --cflags gtk+-3.0`',
'`pkg-config --libs gtk+-3.0`'];
这只是导致这样的错误:因为BASH实际上并没有扩大的表达得到一个错误
gcc: error: `pkg-config --cflags gtk+-3.0`: No such file or directory
那么,有没有什么办法做这个工作?我是否需要手动执行shell扩展:将pkg-config
的输出作为Python字符串获取,然后将其作为module.extra_compile_args
中的元素添加?