1

我使用 SWIG 链接到 gtkglext 的任何内容都会在退出时使 Python 崩溃。为什么会崩溃?

测试.i:

%module test
%{
void test() { printf("Test.\n"); }
%}
void test();

会议:

$ swig -python test.i

$ g++ -I/usr/include/python2.6 -shared -fPIC -o _test.so test_wrap.c -lpython2.6

$ python -c 'import test; test.test()'
Test.

$ g++ -I/usr/include/python2.6 -shared -fPIC -o _test.so test_wrap.c -lpython2.6 `pkg-config --libs gtkglext-1.0`

$ python -c 'import test; test.test()'
Test.
Segmentation fault

有任何想法吗?谢谢...

4

1 回答 1

1

您需要正确初始化 gtk。

$ cat test.i 
%module test
%{
void test() { printf("Test.\n"); }
%}
void test();
$ swig -python test.i ; gcc -I/usr/include/python2.5 -shared -fPIC -o _test.so test_wrap.c -lpython2.5 `pkg-config --libs gtkglext-1.0`
$ python -c 'import test; test.test()'
Test.
Segmentation fault
$ python -c 'import gtk; import test; test.test()'
Test.
于 2009-11-26T10:24:31.777 回答