On 02/21/2010 09:50 PM, Oscar Gerardo Lazo Arjona wrote:
A friend of mine is having trouble compiling this Cython code in a
notebook cell:
%cython
def resto(int n):
lfact=[]
cdef int i
for i in range(1,n):
if n%i ==0:
lfact.append(i)
tot=sum(lfact)
return n-tot
puntos=[(i,resto(i)) for i in range(2,8131)]
print len(puntos)
produces this error in his machine:
Traceback (most recent call last): lfact=[]
File "", line 1, in <module>
File
"/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/lib/python2.6/site-packages/sagenb/misc/support.py",
line 511, in cython_import_all
create_local_c_file=create_local_c_file)
File
"/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/lib/python2.6/site-packages/sagenb/misc/support.py",
line 488, in cython_import
create_local_c_file=create_local_c_file)
File
"/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/lib/python2.6/site-packages/sage/misc/cython.py",
line 409, in cython
raise RuntimeError, "Error compiling %s:\n%s\n%s"%(filename, log, err)
RuntimeError: Error compiling
/home/juan1489/.sage/sage_notebook.sagenb/home/admin/0/code/sage17.spyx:
running build
running build_ext
building
'_home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx_0'
extension
creating build
creating build/temp.linux-i686-2.6
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/include/csage/
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/include/
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/include/python2.6/
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/lib/python2.6/site-packages/numpy/core/include
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/devel/sage/sage/ext/
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/devel/sage/
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/devel/sage/sage/gsl/
-I/home/juan1489/.sage/sage_notebook.sagenb/home/admin/0/code
-I/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local/include/python2.6
-c
_home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx_0.c
-o
build/temp.linux-i686-2.6/_home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx_0.o
-w -O2
creating build/lib.linux-i686-2.6
gcc -pthread -shared
build/temp.linux-i686-2.6/_home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx_0.o
-L/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local//lib/
-lmpfr -lgmp -lgmpxx -lstdc++ -lpari -lm -lcurvesntl -lg0nntl -ljcntl
-lrankntl -lgsl -lgslcblas -latlas -lntl -lcsage -o
build/lib.linux-i686-2.6/_home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx_0.so
-L/home/juan1489/Downloads/sage-4.2.1-linux-Ubuntu_9.10-i686-Linux/local//lib
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
__home_jua...0_code_sage17_spyx.c
<http://localhost:8000/home/admin/0/cells/0/__home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx.c>
__home_jua...ode_sage17_spyx.html
<http://localhost:8000/home/admin/0/cells/0/__home_juan1489__sage_sage_notebook_sagenb_home_admin_0_code_sage17_spyx.html>
It looks like he is running Sage on his local computer. He needs to
have gcc installed in order for Cython to work. In the README, it says
this about compiling from source (he's compiling something from source
here...):
1. Make sure you have the dependencies and 2 GB of free disk space.
Linux (install these using your package manager):
GCC, g++, make, m4, perl, ranlib, and tar.
I believe for his problem, all he needs to do is
sudo apt-get install build-essential
Thanks,
Jason
--
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