DLL in Python

Mike Müller mmueller at dgfz.de
Tue Oct 24 01:17:24 EDT 2000


Alex Martelli schrieb in Nachricht <8t290k0hjb at news2.newsguy.com>...

>> - 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
>the second.

Thanks for yur hint. But don't konw where to put the "__declspec(dllexport)"
.
My Python source looks like this:


def test_int4(x,y):
    return x+y

def test_real(x,y):
    return min(x,y)

def test_sub(x,y,z):
    print "-->",x,y,z,"<--"

but I can not find any hints where the functions went in the frozen.c which
looks like this:

extern unsigned char M_UserDict[];
extern unsigned char M___main__[];
extern unsigned char M_copy[];
extern unsigned char M_exceptions[];
extern unsigned char M_ntpath[];
extern unsigned char M_os[];
extern unsigned char M_posixpath[];
extern unsigned char M_re[];
extern unsigned char M_repr[];
extern unsigned char M_site[];
extern unsigned char M_stat[];
extern unsigned char M_string[];
extern unsigned char M_tempfile[];
extern unsigned char M_types[];

#include "Python.h"

static struct _frozen _PyImport_FrozenModules[] = {
 {"UserDict", M_UserDict, 3396},
 {"__main__", M___main__, 682},
 {"copy", M_copy, 10529},
 {"exceptions", M_exceptions, 10411},
 {"ntpath", M_ntpath, 11509},
 {"os", M_os, 8234},
 {"posixpath", M_posixpath, 10814},
 {"re", M_re, 14219},
 {"repr", M_repr, 4803},
 {"site", M_site, 4805},
 {"stat", M_stat, 2570},
 {"string", M_string, 19250},
 {"tempfile", M_tempfile, 4689},
 {"types", M_types, 1957},
    {0, 0, 0} /* sentinel */
};

int
main(argc, argv)
    int argc;
    char **argv;
{

        PyImport_FrozenModules = _PyImport_FrozenModules;
        return Py_FrozenMain(argc, argv);
}

Searchint for the string "test_int4"  it turns up in M__main__.obj and in
the *.exe generared by nmake.

Where do need to put my dllexport?

Thanks.

Mike






More information about the Python-list mailing list