[f2py] f2py on FreeBSD

Pearu Peterson pearu@cens.ioc.ee
Sat, 16 Mar 2002 21:45:29 +0200 (EET)


Hi Paul,

On Sat, 16 Mar 2002, Paul Magwene wrote:

> I'm trying to build the simple example in the docs.  With the help of 
> the list archives I was able to get the example to build by doing the 
> following:
> 
> 	f2py -c foo.f -m foobar -lfoobar
                                ^^^^^^^^
You don't need to specify that /

> However, when I try to import the shared library that this builds, I get 
> the following Python error:
> 
>  >>> import foobar
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> ImportError: ./foobar.so: Undefined symbol "on_exit"
>  >>>

Try

  f2py -c foo.f -m foobar -lfoobar -DF2PY_REPORT_ATEXIT_DISABLE

And do you know if your C compiler defines a variable that is specific
to FreeBSD? Like __WIN32__ in Win32, or __APPLE__ in MAC.
Then I could disable the F2PY_REPORT_ATEXIT feature also for FreeBSD by
default.


> Note, that if I do run f2py as two separate commands, building a pyf 
> file first:
> 
> 	f2py foo.f -m foobar -h foobar.pyf
> 
> and then
> 
> 	f2py -c foobar.pyf
> 
> I get a slightly different import error:

Yes, this is expected behavior as you must specify source files or
libraries when doing f2py -c. The above two commands are independent. The
first one just creates foobar.pyf file, nothing more. The second one
constructs and builds an extension module from the signatures
in foobar.pyf.  But note that building process requires that you either
supply source files or libraries of functions that you wish to call from
python. So, try

      f2py -c foobar.pyf foo.f -DF2PY_REPORT_ATEXIT_DISABLE

Regards,
	Pearu