Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

linking libraries in cython

Hi!

I have the following problem: I want to link an extern library like for example -lm to cython.

If I now write for example the following problem:

%cython
#clib: m

cdef extern from "math.h":
    double sin(double)

def f(x):
    return sin(x)

I get the following errors:

Traceback (most recent call last):
`File "<stdin>", line 1, in <module>
 File "_sage_input_8.py", line 10, in <module>
 exec compile(u'_support_.cython_import_all("/home/maldun/.sage/sage_notebook.sagenb        /home/admin/0/code/sage14.spyx", globals())
 File "", line 1, in <module>

 File "/home/maldun/sage/sage-4.5.2/local/lib/python2.6/site-packages/sagenb-0.8.2-py2.6.egg  /sagenb/misc/support.py", line 519, in cython_import_all
 create_local_c_file=create_local_c_file)
 File "/home/maldun/sage/sage-4.5.2/local/lib/python2.6/site-packages/sagenb-0.8.2-py2.6.egg/sagenb/misc/support.py", line 496, in cython_import
 create_local_c_file=create_local_c_file)
 File "/home/maldun/sage/sage-4.5.2/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/maldun/.sage/sage_notebook.sagenb/home/admin/0/code/sage14.spyx:
 running build
 running build_ext
 building '_home_maldun__sage_sage_notebook_sagenb_home_admin_0_code_sage14_spyx_0' extension
 creating build
 creating build/temp.linux-x86_64-2.6
 gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/home   /maldun/sage/sage-4.5.2/local/include/csage/ -I/home/maldun/sage/sage-4.5.2/local/include/ -I/home/maldun/sage/sage-4.5.2/local/include/python2.6/ -I/home/maldun/sage/sage-4.5.2/local/lib/python2.6/site-packages/numpy/core/include -I/home/maldun/sage/sage-4.5.2/devel/sage/sage/ext/ -I/home/maldun/sage/sage-4.5.2/devel/sage/ -I/home/maldun/sage/sage-4.5.2/devel/sage/sage/gsl/ -I/home/maldun/.sage/sage_notebook.sagenb/home/admin/0/code -I/home/maldun/sage/sage-4.5.2/local/include/python2.6 -c _home_maldun__sage_sage_notebook_sagenb_home_admin_0_code_sage14_spyx_0.c -o build/temp.linux-x86_64-2.6/_home_maldun__sage_sage_notebook_sagenb_home_admin_0_code_sage14_spyx_0.o -w -O2
 creating build/lib.linux-x86_64-2.6
 gcc -pthread -shared build/temp.linux-x86_64-2.6/_home_maldun__sage_sage_notebook_sagenb_home_admin_0_code_sage14_spyx_0.o -L/home/maldun/sage/sage-4.5.2/local//lib/ -L/home/maldun/sage/sage-4.5.2/local/lib -l: -lm -lmpfr -lgmp -lgmpxx -lstdc++ -lpari -lm -lcurvesntl -lg0nntl -ljcntl -lrankntl -lgsl -lgslcblas -latlas -lntl -lcsage -lpython2.6 -o build/lib.linux-x86_64-2.6/_home_maldun__sage_sage_notebook_sagenb_home_admin_0_code_sage14_spyx_0.so -L/home/maldun/sage/sage-4.5.2/local//lib

/usr/bin/ld: cannot find -l:
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1`

So now my questions: Why does this fail? Am I able to link labraries anyhow? Can I link external libraries into sage that are installed on my system but not in sage like fftw? Or have I to install them somehow into sage before using it?

Thanx in Advance! Maldun