[f2py] wrapping C/C++

Burlen burlen at apollo.sr.unh.edu
Mon Feb 28 20:07:03 EET 2005


Hi, I want to wrap c++ code with f2py, because I need to pass multidimensional arrays between python and c and I like the Numeric arrays in python.

Does any one have a how to? or some simple example?

I have tried my own simple example, but it won't import into python. here is everything:



f2ctest.c

#include<stdio.h>
int f2ctest(int num)
{
  printf( "Test:%i",num);
  return -1;  
}




burlen at quaoar:~/amr/h5reader/src$ f2py -c -m f2c f2ctest.c
numpy_info:
  FOUND:
    define_macros = [('NUMERIC_VERSION', '"\\"23.5\\""')]
    include_dirs = ['/usr/local/include/python2.3']

running build
running config_fc
running build_src
building extension "f2c" sources
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext




>>> ============================================================== RESTART ==============================================================
>>> import f2c

Traceback (most recent call last):
  File "<pyshell#83>", line 1, in -toplevel-
    import f2c
ImportError: dynamic module does not define init function (initf2c)




I tried defining an initf2c in the c source code but then I got:

>>> ============================================================== RESTART ==============================================================
>>> import f2c

Traceback (most recent call last):
  File "<pyshell#87>", line 1, in -toplevel-
    import f2c
SystemError: dynamic module not initialized properly




Any help is greatly appreciated:
Burlen



More information about the f2py-users mailing list