Python DLL Woes

Bruce Dodson bruce_dodson at bigfoot.com
Tue May 7 23:10:45 EDT 2002


Welcome to DLL Hell!  If you are getting to the point where you see that
message, you almost certainly exported the Python function correctly through
a module, e.g. using  Py_InitModule with a method table.  Then the problem
might be that it can find and load the module from the extension DLL, but
can't find and/or load SlgxApi.dll.  Where is SlgxApi.dll in relation to the
Python shell that was running your Python test script?  Where was it in
relation to the C++ test program that was executing the "native" test?


"Rajat Chopra" <rajat at cs.utexas.edu> wrote in message
news:d9773b18.0205071014.51daaed0 at posting.google.com...
> Hello,
>
> I have a DLL with some functions that allow me to connect to a database
> and issue queries and so forth. The DLL itself is written in C++ and I
> have written code in C++ (and C) to utilize the functions within the DLL
> to connect & manipulate the database.
>
> I have a need to wrap the functions in the DLL using Python. I am
> employing the standard methodology (found in the Python DOCS) and
> following the templates I have written in C/C++ to wrap each function in
> the DLL.  However, when I run my Python module I get an error which is
> perplexing.
>
> In C++, I do:
>
> handle = (HINSTANCE) LoadLibrary("SlgxApi.dll");
> typedef LPBYTE (CALLBACK* SLAPI_LOGGEDIN) (void);
> SLAPI_LOGGEDIN LoggedIn;
> LoggedIn = (SLAPI_LOGGEDIN)GetProcAddress(handle, "slapi_LoggedIn");
> boolResult = (BOOL) LoggedIn();
>
> This works fine for this and all other functions directly in C++.
>
> My C++ wrapper to be used by Python, is almost identical:
>
> static PyObject *slgx_LoggedIn(PyObject *self, PyObject *args) {
>
>         handle = (HINSTANCE) LoadLibrary("SlgxApi.dll");
>         typedef LPBYTE (CALLBACK* SLAPI_LOGGEDIN) (void);
>         SLAPI_LOGGEDIN LoggedIn;
>         LoggedIn = (SLAPI_LOGGEDIN)GetProcAddress(handle,
"slapi_LoggedIn");
>         boolResult = (BOOL) LoggedIn();
> }
>
> While I didn't show all the C++ Wrapper code, when I export the wrapper
> and execute it within Python, I get the following error:
>
> ERROR --> Could not find entry point for slapi_LoggedIn
>
> I don't know why I am getting this error and don't really know what would
> be causing it. I'd appreciate any help on your part. (Also, I want to use
> the C++ wrapper approach rather than CALLDLL by Sam Rushing because there
> are some type-specific issues that are most easily resolvable using the
> C++ wrapper).
>
> Thanks,
>
> Rajat





More information about the Python-list mailing list