Subject: RE: Problem building python extensions
From: "Darrell R. Hougen" <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 26 Sep 2001 11:49:24 -0600

Thank you Norman and Jason for your suggestions.

Unfortunately, I am still having problems.  Norman, I followed your suggestion of using a
version of python that is built under cygwin.  I downloaded python-2.1.1 and Numpy
20.2.1.  Both built fine under my installation of cygwin.  Python failed a few tests using
"make test", but nothing looked very important.  I can run the interpreter, import Numeric
and execute commands without any apparent problem.  However, when I attempt to compile my
code, I get the following error:

$ make
gcc -g -Wall -Wshadow -DUSE_DL_IMPORT -I. -I/usr/local/include/Python2.1
-I/usr/local/include/Python2.1/Numeric  -c -o Term.o Term.c
Term.c:429: initializer element is not constant
Term.c:429: (near initialization for `TermObjectType.ob_type')
make: *** [Term.o] Error 1

This is where ob_type is initialized with &PyType_Type, so the error is very similar to
the one I was seeing before, i.e., the variable is not yet defined.

Jason, I agree that there is probably something wrong with the configuration.
Unfortunately, I don't know enough to know how to fix it.  Unfortunately, the config file
associated with 1.5.2 is so different from the config file associated with 2.1 or 2.1.1
that I can't see what to change to solve my problems.  I tried compiling with the
-mno-cygwin, without making any other changes, but that lead to the same error as the one
listed above.

Norman writes:

    >    Darrell R. Hougen writes:
    >  >
    >  >I'm new to using cygwin to build python extension modules and am having
    >  >a fair bit of trouble.  I can build the extension module under Solaris,
    >  >but when I try to build under cygwin, I get the following errors:
    >
    >  < snip >
    >
    >  >I am using active state python 2.1 and gcc 2.95.3-5 on an NT 4.0 box.  I
    >  >downloaded the version of cygwin that I'm using only yesterday, so it
    >  >should be up to date.
    >
    >  AFAIK you need to use a Cygwin compiled Python library
    >  you also need to add a -DUSE_DL_IMPORT to your gcc command line
    >  and link against $LIB_DIR/Python$VER/config/python$VER.dll
    >
    >  Where $LIB_DIR is either /lib/python$VER or /usr/local/lib/python$VER
    >  depending whether you use the distributed python or have compiled it
    >  yourself
    >
    >  If this doesn't work ask again
    >
    >  Norman

Jason writes:

     Since you are using a Win32 Python (i.e., not Cygwin Python), then you
     must built your Python extensions with Mingw gcc or Cygwin gcc with the
     -mno-cygwin option (i.e., Mingw mode).  See the following for a good,
     but somewhat dated, tutorial:

         http://starship.python.net/crew/kernr/mingw32/Notes.html

     Another option is to use Distutils since it knows how to build Win32
     Python extensions using either Mingw gcc or Cygwin gcc -mno-cygwin.

     Jason

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/