mysql-python构建LNK错误

时间:2012-03-28 15:26:40

标签: python visual-c++ mysql-python

希望有人可以帮助这个,我在Win64上使用win32 python 2.7,vc9,按照here步骤,但现在我收到了这个错误:

running build
running build_py
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
running build_ext
building '_mysql' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 "-IC:
\Program Files\MySQL\Connector C 6.0.2\include" -IC:\Python27\include -IC:\Pytho
n27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
_mysql.c
C:\Program Files\MySQL\Connector C 6.0.2\include\config-win.h(24) : warning C400
5: '_WIN32_WINNT' : macro redefinition
        C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\sdkddkver.h(
197) : see previous definition of '_WIN32_WINNT'
C:\Program Files\MySQL\Connector C 6.0.2\include\config-win.h(203) : warning C40
05: 'SIZEOF_OFF_T' : macro redefinition
        c:\python27\include\pyconfig.h(355) : see previous definition of 'SIZEOF
_OFF_T'
C:\Program Files\MySQL\Connector C 6.0.2\include\config-win.h(301) : warning C40
05: 'HAVE_STDDEF_H' : macro redefinition
        c:\python27\include\pyconfig.h(673) : see previous definition of 'HAVE_S
TDDEF_H'
_mysql.c(1364) : warning C4018: '<' : signed/unsigned mismatch
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo
/INCREMENTAL:NO "/LIBPATH:C:\Program Files\MySQL\Connector C 6.0.2\lib\opt" /LIB
PATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild kernel32.lib advapi32.lib wso
ck32.lib mysqlclient.lib /EXPORT:init_mysql build\temp.win32-2.7\Release\_mysql.
obj /OUT:build\lib.win32-2.7\_mysql.pyd /IMPLIB:build\temp.win32-2.7\Release\_my
sql.lib /MANIFESTFILE:build\temp.win32-2.7\Release\_mysql.pyd.manifest
   Creating library build\temp.win32-2.7\Release\_mysql.lib and object build\tem
p.win32-2.7\Release\_mysql.exp

这是错误部分:

_mysql.obj : error LNK2019: unresolved external symbol _mysql_error@4 referenced
 in function __mysql_Exception
_mysql.obj : error LNK2019: unresolved external symbol _mysql_errno@4 referenced
 in function __mysql_Exception
_mysql.obj : error LNK2019: unresolved external symbol _mysql_server_init@12 ref
erenced in function __mysql_server_init
_mysql.obj : error LNK2019: unresolved external symbol _mysql_server_end@0 refer
enced in function __mysql_server_end
_mysql.obj : error LNK2019: unresolved external symbol _mysql_thread_safe@0 refe
renced in function __mysql_thread_safe
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_fields@4 ref
erenced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_fields@4 refer
enced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_store_result@4 ref
erenced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_use_result@4 refer
enced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_connect@32 re
ferenced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_ssl_set@24 referen
ced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_options@12 referen
ced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_init@4 referenced
in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_close@4 referenced
 in function __mysql_ConnectionObject_close
_mysql.obj : error LNK2019: unresolved external symbol _mysql_affected_rows@4 re
ferenced in function __mysql_ConnectionObject_affected_rows
_mysql.obj : error LNK2019: unresolved external symbol _mysql_debug@4 referenced
 in function __mysql_debug
_mysql.obj : error LNK2019: unresolved external symbol _mysql_dump_debug_info@4
referenced in function __mysql_ConnectionObject_dump_debug_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_autocommit@8 refer
enced in function __mysql_ConnectionObject_autocommit
_mysql.obj : error LNK2019: unresolved external symbol _mysql_commit@4 reference
d in function __mysql_ConnectionObject_commit
_mysql.obj : error LNK2019: unresolved external symbol _mysql_rollback@4 referen
ced in function __mysql_ConnectionObject_rollback
_mysql.obj : error LNK2019: unresolved external symbol _mysql_next_result@4 refe
renced in function __mysql_ConnectionObject_next_result
_mysql.obj : error LNK2019: unresolved external symbol _mysql_set_server_option@
8 referenced in function __mysql_ConnectionObject_set_server_option
_mysql.obj : error LNK2019: unresolved external symbol _mysql_sqlstate@4 referen
ced in function __mysql_ConnectionObject_sqlstate
_mysql.obj : error LNK2019: unresolved external symbol _mysql_warning_count@4 re
ferenced in function __mysql_ConnectionObject_warning_count
_mysql.obj : error LNK2019: unresolved external symbol _mysql_escape_string@12 r
eferenced in function __mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_escape_string
@16 referenced in function __mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_lengths@4 re
ferenced in function __mysql_row_to_tuple
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncpy referenced
 in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncat referenced
 in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol _memset referenced in fun
ction __mysql_row_to_dict_old
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_row@4 refere
nced in function __mysql__fetch_row
_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_rows@4 referen
ced in function __mysql_ResultObject_fetch_row
_mysql.obj : error LNK2019: unresolved external symbol _mysql_change_user@16 ref
erenced in function __mysql_ConnectionObject_change_user
_mysql.obj : error LNK2019: unresolved external symbol _mysql_character_set_name
@4 referenced in function __mysql_ConnectionObject_character_set_name
_mysql.obj : error LNK2019: unresolved external symbol _mysql_set_character_set@
8 referenced in function __mysql_ConnectionObject_set_character_set
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_character_set_
info@8 referenced in function __mysql_ConnectionObject_get_character_set_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_client_info@0
referenced in function __mysql_get_client_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_host_info@4 re
ferenced in function __mysql_ConnectionObject_get_host_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_proto_info@4 r
eferenced in function __mysql_ConnectionObject_get_proto_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_server_info@4
referenced in function __mysql_ConnectionObject_get_server_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_info@4 referenced
in function __mysql_ConnectionObject_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_insert_id@4 refere
nced in function __mysql_ConnectionObject_insert_id
_mysql.obj : error LNK2019: unresolved external symbol _mysql_kill@8 referenced
in function __mysql_ConnectionObject_kill
_mysql.obj : error LNK2019: unresolved external symbol _mysql_field_count@4 refe
renced in function __mysql_ConnectionObject_field_count
_mysql.obj : error LNK2019: unresolved external symbol _mysql_ping@4 referenced
in function __mysql_ConnectionObject_ping
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_query@12 refe
renced in function __mysql_ConnectionObject_query
_mysql.obj : error LNK2019: unresolved external symbol _mysql_select_db@8 refere
nced in function __mysql_ConnectionObject_select_db
_mysql.obj : error LNK2019: unresolved external symbol _mysql_shutdown@8 referen
ced in function __mysql_ConnectionObject_shutdown
_mysql.obj : error LNK2019: unresolved external symbol _mysql_stat@4 referenced
in function __mysql_ConnectionObject_stat
_mysql.obj : error LNK2019: unresolved external symbol _mysql_thread_id@4 refere
nced in function __mysql_ConnectionObject_thread_id
_mysql.obj : error LNK2019: unresolved external symbol __imp__sprintf referenced
 in function __mysql_ConnectionObject_repr
_mysql.obj : error LNK2019: unresolved external symbol _mysql_data_seek@12 refer
enced in function __mysql_ResultObject_data_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_row_seek@8 referen
ced in function __mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_row_tell@4 referen
ced in function __mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_free_result@4 refe
renced in function __mysql_ResultObject_dealloc
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
build\lib.win32-2.7\_mysql.pyd : fatal error LNK1120: 56 unresolved externals
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.
exe"' failed with exit status 1120

提前感谢任何帮助或暗示。

1 个答案:

答案 0 :(得分:0)

要在Visual Studio 2012 Express上解决链接器错误,例如“未解析的外部符号__DllMainCRTStartup @ 12”,请添加链接器库: MSVCRT.LIB,MSVCRTD.LIB