Cython chokes on Matrix class cimport (M4RI problem ?)

67 views
Skip to first unread message

Charles Bouillaguet

unread,
Oct 9, 2012, 2:25:39 AM10/9/12
to sage-...@googlegroups.com
Hi all,

I triggered a problem by writing a very simple python file, which only contains one line :

--------
from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense
--------

then, inside sage, running

sage: load "mini_problem.spyx"

raises an error :

sage: load "mini_problem.spyx"
Compiling ./mini_problem.spyx...
Error compiling cython file:
Error compiling ./mini_problem.spyx:
running build
running build_ext
building '_Users_cbouilla_Desktop_svn_eurocrypt_mini_problem_spyx_9' extension
gcc -fno-strict-aliasing -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/cbouilla/Desktop/sage-5.3/local/include/csage/ -I/Users/cbouilla/Desktop/sage-5.3/local/include/ -I/Users/cbouilla/Desktop/sage-5.3/local/include/python2.7/ -I/Users/cbouilla/Desktop/sage-5.3/local/lib/python2.7/site-packages/numpy/core/include -I/Users/cbouilla/Desktop/sage-5.3/devel/sage/sage/ext/ -I/Users/cbouilla/Desktop/sage-5.3/devel/sage/ -I/Users/cbouilla/Desktop/sage-5.3/devel/sage/sage/gsl/ -I. -I/Users/cbouilla/Desktop/sage-5.3/local/include/python2.7 -c _Users_cbouilla_Desktop_svn_eurocrypt_mini_problem_spyx_9.c -o build/temp.macosx-10.7-x86_64-2.7/_Users_cbouilla_Desktop_svn_eurocrypt_mini_problem_spyx_9.o -w -O2

In file included from /Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h:46:0,
from /Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzp.h:31,
from /Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/m4ri.h:56,
from _Users_cbouilla_Desktop_svn_eurocrypt_mini_problem_spyx_9.c:283:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/debug_dump.h: In function ‘calculate_hash’:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/debug_dump.h:34:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/debug_dump.h:34:3: note: use option -std=c99 or -std=gnu99 to compile your code
In file included from /Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzp.h:31:0,
from /Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/m4ri.h:56,
from _Users_cbouilla_Desktop_svn_eurocrypt_mini_problem_spyx_9.c:283:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h: In function ‘_mzd_row_swap’:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h:410:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h: In function ‘mzd_row_swap’:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h:447:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h: In function ‘mzd_hash’:
/Users/cbouilla/Desktop/sage-5.3/local/include/m4ri/mzd.h:1396:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
error: command 'gcc' failed with exit status 1

Is this a local problem ?

Charles

Martin Albrecht

unread,
Oct 9, 2012, 5:05:56 AM10/9/12
to sage-...@googlegroups.com
You'll have specify some pragmas for this code to compile, in your case at
least:

#cargs -c99
#clib m4ri

See here: http://sagemath.org/doc/developer/coding_in_cython.html#special-
pragmas
Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://martinralbrecht.wordpress.com/
_jab: martinr...@jabber.ccc.de

William Alumbaugh

unread,
Oct 19, 2014, 5:47:06 PM10/19/14
to sage-...@googlegroups.com, martinr...@googlemail.com
Small change 
#cargs -std=c99

instead of

#cargs -c99
 
is required now.



Reply all
Reply to author
Forward
0 new messages