help with Linker dependencies missing went compiling mysql-python on Windows without VisualStudio

Jorge Vargas jorge.vargas at gmail.com
Mon May 8 11:37:01 EDT 2006


Hi everyone I'm stuck at doing this and can't find the problem, maybe
someone with more experience then I compiling python can help me out.

I google around and found some old articles, from them the one that seems
more accurate is http://www.vrplumber.com/programming/mstoolkit/

of couse I had to difer from that a little so this is what I have install

   - Microsoft Windows Platform SDK Collection for Windows Server 2003
   SP1
   - Microsoft Visual Studio 2005 Version 8.0.50727.42  (RTM.050727-4200)
   thats Microsoft Visual C++ 2005

I have try with either one install

   - Microsoft .NET framework SDK 1.1
   - Microsoft .NET Framework Version 2.0.50727


On the other part I have

   - Python 2.4.2
   - mysql-4.1.18-win32.zip
   - mysqlpython 1.2.0, 1.2.1 and 1.2.1_p2

-----------------------------------------
Changes to the sources

   - I apply the patch posted on the website, for disutils
   http://www.vrplumber.com/programming/mstoolkit/msvccompiler.patch
   - I commented out the code related to version in _mysql.c ( wont give
   the line numbers cause they differ from file to file.

/*if (PyDict_SetItemString(dict, "version_info",
                   PyRun_String(version_info, Py_eval_input,
                       dict, dict)))
        goto error;
    if (PyDict_SetItemString(dict, "__version__",
                   PyString_FromString(__version_ _)))
        goto error;*/

   - I copy over the file my_config.h from the mysql sources (because
   it's NOT distributed with the installer)
   - and finally I edit site.cfg to this, the rest of the file is not
   changed.

[compiler]
mysqlroot: C:\mysql
library_dirs: %(mysqlroot)s\lib\opt
include_dirs: %(mysqlroot)s\include
libraries: mysqlclient zlib libcmt wsock32 advapi32
# libcmt msvcrt
#extra_compile_args:
#extra_objects:


   - I started the "Visual Studio 2005 Command Prompt"
   - and setup.py build
   - So far I belive I have compile a working copy of the code but i'm
   stuck at the linker

Right now my problem is with the linker the values in site.cfg seems to be
wrong.

libraries: mysqlclient zlib msvcrt libcmt wsock32 advapi32

libs msvcrt libcmt seems to conflict with eachother and with MSVCR80.dll

I have try using msvcrt and have /NODEFAULTLIB:libcrt

C:\MySQL-python-1.2.1_p2.tar\MySQL-python-1.2.1_p2>"C:\Program
Files\Microsoft Visual Studio 8\VC\BIN\link.exe" /DLL /nologo
/INCREMENTAL:NO /LIBPATH:C:\mysql\lib\opt /LIBPATH:c:\python24\libs
/LIBPATH:c:\python24\PCBuild mysqlclient.lib zlib.lib msvcrt.lib wsock32.lib
advapi32.lib /EXPORT:init_mysql
build\temp.win32-2.4\Release\_mysql.obj/OUT:build\lib.win32-
2.4\_mysql.pyd /IMPLIB:build\temp.win32-2.4\Release\_mysql.lib/NODEFAULTLIB:libcrt
LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrt.lib
(MSVCR80.dll)
LIBCMT.lib(fflush.obj) : error LNK2005: _fflush already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(calloc.obj) : error LNK2005: _calloc already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(realloc.obj) : error LNK2005: _realloc already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(crt0init.obj ) : error LNK2005: ___xi_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
msvcrt.lib (cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
msvcrt.libcinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCMT.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined
in msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(winsig.obj) : error LNK2005: _signal already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined
in msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj ) : error LNK2005: __encoded_null already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined
in msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in msvcrt.lib(
MSVCR80.dll)
LIBCMT.lib(setlocal.obj) : error LNK2005: _setlocale already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(tzset.obj) : error LNK2005: __tzset already defined in msvcrt.lib
(MSVCR80.dll)
LIBCMT.lib(_ctype.obj) : error LNK2005: _isspace already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(_ctype.obj) : error LNK2005: _iscntrl already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(atox.obj) : error LNK2005: _atoi already defined in msvcrt.lib(
MSVCR80.dll)
LIBCMT.lib(getenv.obj) : error LNK2005: _getenv already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(strtol.obj) : error LNK2005: _strtol already defined in
msvcrt.lib(MSVCR80.dll)
LIBCMT.lib(strtol.obj) : error LNK2005: _strtoul already defined in
msvcrt.lib(MSVCR80.dll)
   Creating library build\temp.win32-2.4\Release\_mysql.lib and object
build\temp.win32-2.4\Release\_mysql.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other
libs; use /NODEFAULTLIB:library
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
referenced in function ___tmainCRTStartup
build\lib.win32-2.4\_mysql.pyd : fatal error LNK1120: 1 unresolved externals

I have try using libcmt and have /NODEFAULTLIB:msvcrt

C:\MySQL-python-1.2.1_p2.tar\MySQL-python-1.2.1_p2>"C:\Program
Files\Microsoft Visual Studio 8\VC\BIN\link.exe" /DLL /nologo
/INCREMENTAL:NO /LIBPATH:C:\mysql\l ib\opt /LIBPATH:c:\python24\libs
/LIBPATH:c:\python24\PCBuild mysqlclient.lib zlib.lib libcmt.lib wsock32.lib
advapi32.lib /EXPORT:init_mysql build\temp.win32-2 .4\Release\_mysql.obj
/OUT:build\lib.win32-2.4\_mysql.pyd /IMPLIB:build\temp.win
32-2.4\Release\_mysql.lib /NODEFAULTLIB:msvcrt
   Creating library build\temp.win32-2.4\Release\_mysql.lib and object
build\temp.win32-2.4\Release\_mysql.exp
_mysql.obj : warning LNK4217: locally defined symbol _sprintf imported in
function __mysql_ConnectionObject_repr
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncat
referenced in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncpy
referenced in function __mysql_row_to_dict
build\lib.win32-2.4\_mysql.pyd : fatal error LNK1120: 2 unresolved externals

And I have also try using none. of them, please note this is the same as the
above

C:\MySQL-python-1.2.1_p2.tar\MySQL-python-1.2.1_p2>"C:\Program
Files\Microsoft Visual Studio 8\VC\BIN\link.exe" /DLL /nologo
/INCREMENTAL:NO /LIBPATH:C:\mysql\lib\opt /LIBPATH:c:\python24\libs
/LIBPATH:c:\python24\PCBuild mysqlclient.lib zlib.lib wsock32.lib
advapi32.lib /EXPORT:init_mysql
build\temp.win32-2.4\Release\_mysql.obj/OUT:build\lib.win32-
2.4\_mysql.pyd /IMPLIB:build\temp.win32-2.4\Release\_mysql.lib/NODEFAULTLIB:msvcrt
/NODEFAULTLIB:libcrt
   Creating library build\temp.win32-2.4\Release\_mysql.lib and object
build\temp.win32-2.4\Release\_mysql.exp
_mysql.obj : warning LNK4217: locally defined symbol _sprintf imported in
function __mysql_ConnectionObject_repr
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncat
referenced in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncpy
referenced in function __mysql_row_to_dict
build\lib.win32-2.4\_mysql.pyd : fatal error LNK1120: 2 unresolved externals

now the weird thing is that i'm missing some very common functions I even
try adding

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>

to the mysql.c file and they are still missing.

my site.cfg mysql section is

[compiler]
mysql_root: C:\mysql
library_dirs: %(mysql_root)s\lib\opt
include_dirs: %(mysql_root)s\include
libraries: mysqlclient zlib libcmt wsock32 advapi32
# libcmt msvcrt
#extra_compile_args:
#extra_objects:

I have also notice I have multiple versions of libcmt.lib and  msvcrt.lib
one in C:\Program Files\Microsoft Visual Studio 8\VC\lib and another in
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib

I have try with both and still having the same error.

sorry for the long message but it's a complex problem so it needs big
files:)

any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060508/ac848d78/attachment.html>


More information about the Python-list mailing list