On Nov 23, 2009, at 11:45 AM, Jorge E. ´Sanchez Sanchez wrote:

>    Robert:
>
>    Now I am understanding, in the William Stein's example he could  
> get an executable hw:
>    Now I can in fact do: cython --embed hw.py without any complains
>    but when I try to gcc-compile, I got a message involving the main  
> (see below), so I thought
>    that this feature is not working for me:
>
> sage subshell$ gcc -I /opt/sage-4.2.1/local/include/python2.6 /opt/ 
> sage-4.2.1/local/lib/libpython2.6.a -o hw hw.c
> /tmp/ccGXE0bt.o: In function `__pyx_pf_2hw_hello_world':
> hw.c:(.text+0x3c): undefined reference to `_Py_NoneStruct'

[...]

> hw.c:(.text+0x156b): undefined reference to `PyObject_IsTrue'
> collect2: ld returned 1 exit status
> /home/george
> sage subshell$

This means you're missing am -L flag and -lpython2.6 (is there  
supposed to be a space there?), or something like that. That's why I  
never actually run the command manually--too many flags to remember.  
(When using setup.py, you can see the exact gcc command that's used,  
and use that one...)

>    That's why I used setup.py instead, but then I end with a .so file,
>     very little in size compared with the one William got:
>     sage subshell$ ls -lh hw.so
>     -rwxr-xr-x 1 george george 39K 2009-11-21 21:38 hw.so
>  .
>    And also that's why in his example, within the sage shell he just  
> type:
>    ./hw
>    and got it running, but when I try this:
> bash: ./hw: No such file or directory
>    and I supposed that I had to add the extension and end with the  
> Segmentation fault message.

When you compile within Sage it's using library paths, etc. that are  
set up differently outside of the sage shell. Maybe it's even using a  
different version of Python, which could be bad. You can create the .c  
file within the shell, and then manually compile it with gcc out of  
the shell, and it should work outside the shell.

>    Just to get rid of my curiosity, could you see what am I missing  
> to finish the compilation?

See above.

- Robert

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to