Carl <ph***********@chello.se> writes:
I have experimented with f2c and swig-generated wrappers to create python
modules from Fortran files.
I think I'm missing something when I'm building the Python module, because
when I import the built module the Python interpreter returns the
following:
import LDSsobol
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "LDSsobol.py", line 4, in ?
import _LDSsobol
ImportError: /usr/lib/libf2c.so.0: undefined symbol: MAIN__
This is how I built LDSsobol:
gcc -c LDSsobol.c
gcc -c LDSsobol_wrap.c -I/usr/include/python
gcc -shared LDSsobol.o LDSsobol_wrap.o -l f2c -o _LDSsobol.so
Hello Carl,
Googleing for "libf2c.so.0: undefined symbol: MAIN__" I found only 8
hits, some links broken, but also
<http://www.physics.orst.edu/~bertrand/slatec/jnislatec/JNI_Slatec.html>
where I found:
Currently users of f2c will probably encounter the following message:
"libf2c.so.0: undefined symbol: MAIN__ ". Again, the culprit is that
all references must be resolved, and libf2c.so unfortunately contains
a reference to some dummy function. Fortunately the fix is simple,
include the following snippet in your C native source (in our example
mynativecalls.c):
int MAIN__( )
{ return(0);
}
Another solution (not tested) could be to use "-lg2c" instead of
"-lf2c". As I understand it, the g77 runtime library is derived from
the f2c runtime library. An even better (in my opinion) solution would
be to use "f2py" from <http://cens.ioc.ee/projects/f2py2e/>, a tool to
wrap python (and C) code for python.
Regards
Berthold
--
bh***@web.de /
http://starship.python.net/crew/bhoel/