2016-04-08 12 views
-1
$cat say.py 
print('Hello World!') 

$python --version 
Python 2.7.11+ 

$python say.py 
Hello World! 

$cython --version 
Cython version 0.23.4 

$cython say.py 
$gcc `pkg-config --cflags --libs python` -o say say.c -lpython2.7 -lpthread -lm -lutil -ldl -fPIC -shared 

$./say 
Segmentation fault (core dumped) 
+0

Können Sie erklären, was Sie zu tun versuchen? – ShadowMitia

Antwort

0

gcc kompiliert eine Modul, die von Python importiert werden können:

% cython say.py 
% gcc `pkg-config --cflags --libs python` -o say.so say.c -lpython2.7 -lpthread -lm -lutil -ldl -fPIC -shared 
% /bin/rm say.py # make sure we aren't just importing say.py 
% ls -l say* 
-rwxrwxr-x 1 unutbu unutbu 19693 Apr 8 07:52 say.so 
-rw-rw-r-- 1 unutbu unutbu 68614 Apr 8 07:52 say.c 

% python 
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import say 
Hello World! 
>>> 

Siehe auch "Building Cython Code" für andere bessere Möglichkeiten Cython Code zu bauen.

+0

Danke. Problem gelöst! – Cogumelos