Problem compiling Python 2.0 extension under Win32

Alex Martelli aleaxit at yahoo.com
Thu Oct 26 03:41:41 EDT 2000


"Gerhard Häring" <gerhard_haering at yahoo.com> wrote in message
news:39F7DDDB.B1A63D21 at yahoo.com...
> Hi folks,
>
> I have just tried to make compile the MySQL database module with Python
> 2.0 headers/libs under Win32 with Visual C++. I have already tried
> several options, but I alwyays get the following messages at the linking
> stage:
>
> _mysqlmodule.obj : error LNK2001: unresolved external symbol
> __imp___Py_Dealloc
> _mysqlmodule.obj : error LNK2001: unresolved external symbol
> __imp___Py_RefTotal
> _mysqlmodule.obj : error LNK2001: unresolved external symbol
> __imp__Py_InitModule4TraceRefs
>
> I think the __imp__ is the problem. It should not be in the identifier,
> should it? I couldn't figure out where and why this gets into the
> symbols. Has anybody already had this problem, any ideas?

The __imp__ decoration signifies that this symbol is meant to come
from an "import library" -- the kind of .LIB file that refers to a
separate .DLL file, rather than holding the object-code itself.  It
is, therefore, absolutely *not* a problem in itself -- indeed, it
is encouraging, since we know that on Win32/VC++ Python *is* in
fact housed in a DLL (so the symbols that a C extension needs from
it will in fact come from its "import library").

That these symbols can't be found by the linker suggests that the
correct Python import-library is NOT in the linker's command-line!

If you're using distutils and 'python setup.py install' or something
similar, this suggests your distutil installation is flawed.  If
you're using a MSVC++ IDE workspace (.dsw/.dsp files), the defect
must be there (or in your IDE's Options/Directories.../Libraries
settings).  If you're using a makefile, then the defect must be in
the makefile or in your environment-variable settings.  Ditto if
a .BAT or .CMD file (or manual command-line compilation/link:-).

In any case, what you must do is ensure that the python20.lib is
part of the link (and no other older pythonsomething.lib is) and
that it comes from the right directory.  How to ensure it depends
on the build approach used in the "several options" you tried.


Alex






More information about the Python-list mailing list