On Nov 23, 2009, at 6:58 PM, Jorge E. ´Sanchez Sanchez wrote: > Robert: > > I am so sorry for bothering you again with my silly questions but > I am still walking in circles around the > correct compilation flags. Here's how I am succeded to build > hibehnel.py as executable, where hibehnel.py is: > > sage subshell$ more hibehnel.py > def hello_world(): > import sys > print "Welcome to Python %d.%d!" % sys.version_info[:2] > > if __name__ == '__main__': > hello_world() > > -> cython --embed hibehnel.py to get hibehnel.c > > Then I made a batch named xCython to compile the files $1.c with > the line: > > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- > prototypes -fPIC -I/usr/local/include -I/opt/sage-4.2.1/local/ > include/python2.6 -o o$1 $1.c -lpython2.6 -lpthread -lm -lutil -ldl > > on it. > > then after giving: > > ./xCython hibehnel > /opt/sage-4.2.1/local/lib/../lib/libpython2.6.a(posixmodule.o): In > function `posix_tmpnam': > /opt/sage-4.2.1/spkg/build/python-2.6.2.p4/src/./Modules/ > posixmodule.c:7129: warning: the use of `tmpnam_r' is dangerous, > better use `mkstemp' > /opt/sage-4.2.1/local/lib/../lib/libpython2.6.a(posixmodule.o): In > function `posix_tempnam': > /opt/sage-4.2.1/spkg/build/python-2.6.2.p4/src/./Modules/ > posixmodule.c:7084: warning: the use of `tempnam' is dangerous, > better use `mkstemp' > /home/george > > although those warnings I got the executable "ohibehnel": > > sage subshell$ ./ohibehnel > Welcome to Python 2.6! > /home/george > > working as it has to do, as expected.
Good. > But now trying with the William Stein's hw.py > > /home/george > sage subshell$ ./xCython hw > /opt/sage-4.2.1/local/lib/../lib/libpython2.6.a(posixmodule.o): In > function `posix_tmpnam': > /opt/sage-4.2.1/spkg/build/python-2.6.2.p4/src/./Modules/ > posixmodule.c:7129: warning: the use of `tmpnam_r' is dangerous, > better use `mkstemp' > /opt/sage-4.2.1/local/lib/../lib/libpython2.6.a(posixmodule.o): In > function `posix_tempnam': > /opt/sage-4.2.1/spkg/build/python-2.6.2.p4/src/./Modules/ > posixmodule.c:7084: warning: the use of `tempnam' is dangerous, > better use `mkstemp' > /home/george > > again although those same warnings I got the executable "ohw": > but now ... > > /home/george > sage subshell$ ./ohw > Traceback (most recent call last): > File "hw.py", line 1, in hw (hw.c:561) > import sage.all > File "/opt/sage-4.2.1/local/lib/python2.6/site-packages/sage/ > all.py", line 44, in <module> > import twisted.persisted.styles > File "/opt/sage-4.2.1/local/lib/python2.6/site-packages/twisted/ > __init__.py", line 18, in <module> > from twisted.python import compat > File "/opt/sage-4.2.1/local/lib/python2.6/site-packages/twisted/ > python/compat.py", line 15, in <module> > import sys, string, socket, struct > File "/opt/sage-4.2.1/local/lib/python/socket.py", line 46, in > <module> > import _socket > ImportError: /opt/sage-4.2.1/local/lib/python2.6/lib-dynload/ > _socket.so: undefined symbol: PyExc_ValueError > /home/george That's strange, what happens if you do "import socket" right at the sage prompt? In any case, if you do "from sage.all import ..." you might have to potentially link in every library that Sage builds (trust me, there's a lot of them) to create a standalone executable with the --embed option. This will work on OS X where you don't have to explicitly link dynamic libraries. - 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