[英]swig mysql: undefined symbol: mysql_init'
I am trying to create a swig package for python that offers mysql connectivity. 我正在尝试为提供mysql连接的python创建一个swig包。 But when I try to import the package in python I get the following error: 但是,当我尝试在python中导入包时,出现以下错误:
-> _mod = imp.load_module('_IMysqlConnection', fp, pathname, description)
(Pdb) s
ImportError: './_IMysqlConnection.so: undefined symbol: mysql_init'
I am creating the package using the following commands (probably this is where I am making a blunder) 我正在使用以下命令创建程序包(可能这是我犯错误的地方)
$swig -c++ -python -o IMysqlConnection_wrap.cc IMysqlConnection.i
$ gcc -fPIC -c IMysqlConnection_wrap.cc -o IMysqlConnection_wrap.o -I /usr/include/python2.6/ `mysql_config --cflags` `mysql_config --libs`
g$ gcc -fPIC -c IMysqlConnection.cc -o IMysqlConnection.o -I . /usr/include/python2.6/ `mysql_config --cflags` `mysql_config --libs`
$ g++ -shared IMysqlConnection_wrap.o IMysqlConnection.o -o _IMysqlConnection.so
I am able to do mysql connectivity when I use this class (IMysqlConnection.cc) in C++ main. 当我在C ++ main中使用此类(IMysqlConnection.cc)时,我能够进行mysql连接。
Any help and guidance will me much appreciated. 任何帮助和指导,我将不胜感激。
You can use http://sourceforge.net/projects/mysql-python/ 您可以使用http://sourceforge.net/projects/mysql-python/
This does not exactly answer your connection though. 但是,这不能完全回答您的连接。
Solved: I was missing mysql_config --cflags
mysql_config --libs
while creating the shared library _IMysqlConnection.so 解决:创建共享库_IMysqlConnection.so时缺少mysql_config --cflags
mysql_config --libs
--libs
g++ -shared CMysqlConnection_wrap.o CMysqlConnection.o -o _CMysqlConnection.so mysql_config --cflags
mysql_config --libs
g ++-共享的CMysqlConnection_wrap.o CMysqlConnection.o -o _CMysqlConnection.so mysql_config --cflags
mysql_config --libs
Above command linked mysql library to the shared library _IMysqlConnection.so and it worked fine. 上面的命令将mysql库链接到共享库_IMysqlConnection.so,并且运行良好。
Thanks Ugo for your help :-) 感谢Ugo的帮助:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.