DLL in Python
aleaxit at yahoo.com
Mon Oct 23 22:53:02 CEST 2000
"Mike Müller" <mmueller at dgfz.de> wrote in message
news:8t1e4p$gok at micky.ibh-dd.de...
> I need to supply a DLL, which will be called by a third party FORTRAN
> program. I would like to write this DLL in Python. I am not sure what
> be the best way to this.
> - Looking at the freeze utility I don't see where in the frozen.c I can
> define the dll export.
As you later say that you're using VC++6, you have several
ways to tell the compiler and linker what symbols it should
export: put the "__declspec(dllexport)" attribute in the C
source of the functions you're exporting, add a .DEF file to
your project with the list of exports, use the /EXPORT flag
on the linker's runtime. If you don't care about the C source
being portable, the first is probably easiest; if you do, then
> - Another option would be to embed the Python interpreter in a C-program,
> which in turn will be a DLL.
Sure, but you still have the same ways to tell the compiler
and linker what symbols the DLL should export.
> I am working with VC++ 6.0 which is integrated with Digital FORTRAN
> 6.1 (so the connection between C and FORTRAN should be no problem).
> I dont have much experience with C/C++ (just recently compiled my first
> Python extension) so minimizing the work in C would be good.
Well, there's not much C work you need to do with either of
these approaches, but I guess the amount may be lower with
the freeze idea -- you only need to add the functions you want
to export, which in turn call to Python.
Still, on Windows, there's a way to do even less work, and
_none_ of it in C, but...:
> Also, since the program needs to be installed on a different computer, the
> installation of a full-blown Python interpreter with lots of modules is
> an option.
...it may not be compatible with the idea of "a full-blown interpreter
with lots of modules", since it would probably require a few DLL's --
it's based on using Python to implement COM servers, and Fortran
to use those servers (I don't know how good Digital Fortran 6.1 is
at calling COM servers, but modern language implementations on
Windows usually have few problems doing that).
More information about the Python-list