[f2py] static libraries
Stephen Skory <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I would like to build a f2py module into a static library, rather than the default shared library/object. This is because I want to run my module on a Cray XT5, and the kernel on the compute nodes do not allow shared objects to be loaded by executables. Rather, the modules must be statically linked into Python at build time by being added to the Modules/Setup file in the Python source directory.
I can successfully build and run this module on my Mac, but then it's a shared object, of course. But it eliminates the module itself as the source of the problem.
I have tried putting -static in place of "opt.append("-shared")" in lib/python2.6/site-packages/numpy/distutils/fcompiler/gnu.py (it's at line 106 in my version), and that doesn't work. I'm calling f2py like this, just like on my Mac:
f2py -c py_kdtree2.pyf py_kdtree2.f90 kdtree2.f90
and the errors come from this part of the build process:
/opt/gcc/4.2.0.quadcore/bin/gfortran -Wall -Wall -static /tmp/tmpjKd0rh/tmp/tmpjKd0rh/src.linux-x86_64-2.6/py_kdtree2module.o /tmp/tmpjKd0rh/tmp/tmpjKd0rh/src.linux-x86_64-2.6/fortranobject.o /tmp/tmpjKd0rh/kdtree2.o /tmp/tmpjKd0rh/py_kdtree2.o -L/opt/gcc/4.2.0.quadcore/snos/lib/gcc/x86_64-suse-linux/4.2.0 -lgfortran -o ./py_kdtree2.a
/tmp/tmpjKd0rh/tmp/tmpjKd0rh/src.linux-x86_64-2.6/py_kdtree2module.o: In function `int_from_pyobj':
/tmp/tmpjKd0rh/src.linux-x86_64-2.6/py_kdtree2module.c:110: undefined reference to `PyNumber_Int'
/tmp/tmpjKd0rh/src.linux-x86_64-2.6/py_kdtree2module.c:116: undefined reference to `PyComplex_Type'
/tmp/tmpjKd0rh/src.linux-x86_64-2.6/py_kdtree2module.c:116: undefined reference to `PyComplex_Type'
...
...
I have tried adding various things to the gfortran line like -I/path/to/include/python2.6 (where Python.h lives), or -L/path/to/lib/ -lpython2.6, but that only increases the variety of errors and it doesn't feel like I'm making it any better.
Thank you for any help you can give me!
Stephen Skory