DLL in Python

Alex Martelli aleaxit at yahoo.com
Tue Oct 24 11:23:24 EDT 2000


"Mike Müller" <mmueller at dgfz.de> wrote in message
news:8t45h8$6h0 at micky.ibh-dd.de...
> Alex,
>
> thanks for your advise.
> I tried to compile the following *.cpp file, which is just a cut and paste
> from what you posted previously:
>
> include <stdio.h>
> #include <Python.h>
>
> PyObject* module_object;

Ooops, you also need a line of

#include <windows.h>

at the start, to define the various uppercased identified
in the following:

> BOOL APIENTRY DllMain( HANDLE hModule,
>                        DWORD  ul_reason_for_call,
>                        LPVOID lpReserved
>       )
> {
>     if(ul_reason_for_call == DLL_PROCESS_ATTACH) {

etc, etc.

Since you're apparently trying to build this from within Visual
Studio, remember, also, to put this source in a project of the
appropriate kind (a DLL, aka dynamic library; NOT a "windows
application", "console application", "static library", or any
of several other project-kinds).  The only setting that you *must*
change from those the project-wizard places for you is the
"runtime library", which MUST be "Multithreadedl DLL" if you
are to run with the ordinary Python20.DLL (I don't think you
want to debug Python itself, so I doubt you want the debug
Python DLL -- nor debug the C runtime, so you don't really want
the debug-multithreaded DLL for _that_...).  If you build a
debug configuration anyway, as you seemed to be doing, it may
be better to remove the setting of DEBUG from the preprocessor
(as it may expect a debug-runtime); or, build some sort of
Release configuration instead (you're not going to debug the
C part of this anyway...).


Alex






More information about the Python-list mailing list