[SciPy-dev] SciPy on Cygwin

Jochen Küpper jochen at jochen-kuepper.de
Fri Sep 28 09:48:13 CDT 2001

A little further, but now I am having linking problems. See end of
message for current problem:

Since I apparently couldn't subscribe to scipy-dev yet send me a cc,

>>>>> Jochen Küpper wrote on 27 Sep 2001 10:26:13 -0400:

[SciPy on Cygwin...]

Jochen> ,----[flapackmodule.c: 447]
Jochen> | PyObject *cb_cselect_in_cgees__user__routines_capi = Py_None;
Jochen> `----

Jochen> I am not sure what to do about that?

>>>>> Jason Tishler wrote on Thu, 27 Sep 2001 16:48:48 -0400:

Jason> The usually solution to the above kind of errors is the
Jason> following:

Jason> http://www.python.org/doc/FAQ.html#3.24

Jason> Unfortunately, the above line does *not* seem to jib with this solution.

Right. And compiling with g++ reveals a ton of other errors.

>>>>> Travis Oliphant wrote on Thu, 27 Sep 2001 11:19:26 -0600 (MDT):

Travis> Well it looks like some more ifdefs are needed.

Travis> I think there is some DL_EXPORT macro that needs to be used somewhere for
Travis> it to work on CYGWIN.  Because this is an f2py generated file, I'm not
Travis> sure what to do.  Does f2py support Cygwin?

I actually tried to put DL_EXPORT macros at different position, but
since I pretty clueless about both Cygwin and python C-extensions I
don't have too much of an understanding where it has to go:(

>>>>> Pearu Peterson wrote on Thu, 27 Sep 2001 20:10:57 +0200 (EET):

Pearu> I have never tried cygwin but it is basically gcc (right?) and therefore
Pearu> I did not see any reasons why f2py generated code would fail on
Pearu> cygwin. However, it seems that I need to let f2py to put lines like 477
Pearu> above to init<module> () block. But if there is a way to use macros please
Pearu> let me know - the fix will be certainly simpler for me.

Pearu> Meanwhile I suggest manually moving the initializations with Py_None to
Pearu> the function flapackmodule(). (I am not sure when I am able to fix f2py
Pearu> as it will not be trivial).

>>>>> Pearu Peterson wrote on Thu, 27 Sep 2001 20:16:32 +0200 (EET):
Pearu> I meant to the function initflapack().

Well, that could be a solution for me since it isn't too much work, a
appropriate putch could probable even be applied by setup.py?

Running into the next problem is the definition of PyFortran_Type in
fortranmodule.h, I changed in the following way:

- no global initialization:

PyTypeObject PyFortran_Type;

- created this function in fortranmodule.c, added declaration to
fortranmodule.h and call it from initflapack:

void fortranobject_init(void) {
  PyFortran_Type = (PyTypeObject){
    0,			/*ob_size*/
    "fortran",			/*tp_name*/
    sizeof(PyFortranObject),	/*tp_basicsize*/
    0,			/*tp_itemsize*/
    /* methods */
    (destructor)fortran_dealloc, /*tp_dealloc*/
    0,			/*tp_print*/
    (getattrfunc)fortran_getattr, /*tp_getattr*/
    (setattrfunc)fortran_setattr, /*tp_setattr*/
    0,			/*tp_compare*/
    0,			/*tp_repr*/
    0,			/*tp_as_number*/
    0,			/*tp_as_sequence*/
    0,			/*tp_as_mapping*/
    0,			/*tp_hash*/
    (ternaryfunc)fortran_call,                    /*tp_call*/

Does this look like a reasonable idea?

Well, it compiles, but I get undefined references on linking.

> gcc -shared -Wl,--enable-auto-image-base
build/temp.cygwin-1.3.3-i686-2.1/fortranobject.o -L/usr/local/lib
-L/usr/lib/python2.1/config -L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5
-Lbuild/temp.cygwin-1.3.3-i686-2.1 -Lbuild/temp.cygwin-1.3.3-i686-2.1
-llapack -lcblas -lf77blas -latlas -lpython2.1 -lamos -ltoms -lfitpack
-lminpack -lquadpack -lodepack -llinpack_lite -lmach -lg2c -lgcc
-lc_misc -lcephes -o

build/temp.cygwin-1.3.3-i686-2.1/flapackmodule.o: In function `initflapack':
/home/software/scipy/linalg/flapackmodule.c:7855: undefined reference to `_imp__PyFortranObject_NewAsAttr'
build/temp.cygwin-1.3.3-i686-2.1/fortranobject.o: In function `PyFortranObject_New':
/home/software/scipy/linalg/fortranobject.c:138: undefined reference to `_imp__PyFortran_Type'
/home/software/scipy/linalg/fortranobject.c:146: undefined reference to `_imp__PyFortranObject_NewAsAttr'
build/temp.cygwin-1.3.3-i686-2.1/fortranobject.o: In function `PyFortranObject_NewAsAttr':
/home/software/scipy/linalg/fortranobject.c:168: undefined reference to `_imp__PyFortran_Type'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

As I said above I tried playing with DL_EXPORTS, to no avail.

Thank you for your help, hope you guys have some more ideas...:))

Einigkeit und Recht und Freiheit                http://www.Jochen-Kuepper.de
    Liberté, Égalité, Fraternité                GnuPG key: 44BCCD8E
        Sex, drugs and rock-n-roll

More information about the Scipy-dev mailing list