undefined symbol in _mysql.so

Alex Lai
2013-03-09
2013-10-22
  • Alex Lai
    Alex Lai
    2013-03-09

    Hi Gurus,
    I'm have trouble making my MySQL-python-1.2.4 work. I install the module using easy_install:

    /usr/local/Python-2.7/bin/easy_install-2.7 MySQL-python-1.2.4

    When I tried to import the module, python gave the following errors:

    /usr/local/Python-2.7/bin/python2.7

    import MySQLdb
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/MySQLdb/init.py", line 19, in <module>
    import _mysql
    ImportError: /usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so: undefined symbol: __cxa_pure_virtual

    ldd on _mysql.so showed some function as undefined:

    ]# ldd -d -r /usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so
    undefined symbol: cxa_pure_virtual (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv120si_class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv117class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv121vmi_class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol:
    gxx_personality_v0 (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZdaPv (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _Znwm (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZdlPv (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _Znam (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    linux-vdso.so.1 => (0x00007fffa7fff000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f914c749000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f914c4c4000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f914c2bc000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f914c0b8000)
    libpython2.7.so.1.0 => /usr/local/Python-2.7/lib/libpython2.7.so.1.0 (0x00007f914bcda000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f914bac4000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f914b733000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003fb3e00000)
    libz.so.1 => /usr/local/Python-2.7/lib/libz.so.1 (0x00007f914b61e000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f914b41b000)

    Could anyone please guild me the right direction?

    Your input is highly appreciated!

    Alex

     
  • Alex Lai
    Alex Lai
    2013-03-09

    I installed the following mysql packages:
    [root@sdpvvrsp810 bin]# rpm -qa|grep -i mysql
    MySQL-shared-5.6.10-1.el6.x86_64
    MySQL-server-5.6.10-1.el6.x86_64
    MySQL-shared-compat-5.6.10-1.el6.x86_64
    MySQL-client-5.6.10-1.el6.x86_64
    MySQL-devel-5.6.10-1.el6.x86_64

    and here are information related to GCC:

    [root@sdpvvrsp810 python-modules]# gcc --version
    gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    [root@sdpvvrsp810 python-modules]# strings -a /usr/local/Python-2.7/bin/python2.7|grep GCC
    GCC: (GNU) 4.4.4 20100726 (Red Hat 4.4.4-13)
    GCC: (GNU) 4.4.5 20110214 (Red Hat 4.4.5-6)

    [root@sdpvvrsp810 python-modules]# strings -a /usr/sbin/mysqld|grep GCC|uniq
    Mutexes and rw_locks use GCC atomic builtins
    GCC_3.0
    GCC: (GNU) 4.4.4 20100726 (Red Hat 4.4.4-13)
    GCC: (GNU) 4.4.5 20110214 (Red Hat 4.4.5-6)
    _Unwind_Resume@@GCC_3.0

     
  • Andy Dustman
    Andy Dustman
    2013-03-09

    Try building an RPM package instead:

    python setup.py bdist_rpm
    

    The resulting RPM package will be in the dist directory.

     
  • Alex Lai
    Alex Lai
    2013-03-09

    Hi Andy,
    Thank for you reply.
    When I install the resulting RPM, will it be install in the corrrect directory? I have a custom python2.7.3 install. My system python is python2.6.6. I want to install the module for python2.7.3.
    BTW, my server is a VMware virtual machine.

    Regards,
    Alex

     
  • Alex Lai
    Alex Lai
    2013-03-09

    It seemed that bdist_rpm is not workin[root@sdpvvrsp810 MySQL-python-1.2.4][root@sdpvvrsp810 MySQL-python-1.2.4]# /usr/local/Python-2.7/bin/python2.7 setup.py bdist_rpm
    running bdist_rpm
    error: error in setup.cfg: command 'bdist_rpm' has no such option 'install_requires'

     
  • Alex Lai
    Alex Lai
    2013-03-09

    I tried build using:
    [root@sdpvvrsp810 python-modules]# echo $LD_LIBRARY_PATH
    /usr/lib64/mysql:/usr/lib/mysql:/usr/local/Python-2.7/lib:/usr/lib64:/lib64:/usr/lib:/lib
    [root@sdpvvrsp810 python-modules]# echo $LDFLAGS
    -L/usr/lib64/mysql -L/usr/local/Python-2.7/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4
    [root@sdpvvrsp810 python-modules]# /usr/local/Python-2.7/bin/python2.7 setup.py build

    the output showed the gcc commands generated are:

    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -Dversion=1.2.4 -I/usr/include/mysql -I/usr/local/Python-2.7/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
    In file included from _mysql.c:44:
    /usr/include/mysql/my_config.h:442:1: warning: "HAVE_WCSCOLL" redefined
    In file included from /usr/local/Python-2.7/include/python2.7/Python.h:8,
    from _mysql.c:29:
    /usr/local/Python-2.7/include/python2.7/pyconfig.h:890:1: warning: this is the location of the previous definition
    gcc -pthread -shared -L/usr/lib64/libpython2.6.so -L/usr/lib64/mysql -L/usr/local/Python-2.7/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4 build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -L/usr/local/Python-2.7/lib -lmysqlclient_r -lpthread -lm -lrt -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so

    But the same issue persists:

    [root@sdpvvrsp810 python-modules]# /usr/local/Python-2.7/bin/python2.7

    import MySQLdb
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/MySQLdb/init.py", line 19, in <module>
    import _mysql
    ImportError: /usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so: undefined symbol: __cxa_pure_virtual
    exit()

    [root@sdpvvrsp810 python-modules]# ldd -d -r /usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so
    undefined symbol: cxa_pure_virtual (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv120si_class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv117class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZTVN10
    cxxabiv121vmi_class_type_infoE (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol:
    gxx_personality_v0 (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZdaPv (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _Znwm (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _ZdlPv (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    undefined symbol: _Znam (/usr/local/Python-2.7/lib/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg/_mysql.so)
    linux-vdso.so.1 => (0x00007fff0f1ff000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa55c6f1000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fa55c46c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007fa55c264000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007fa55c060000)
    libpython2.7.so.1.0 => /usr/local/Python-2.7/lib/libpython2.7.so.1.0 (0x00007fa55bc82000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa55ba6c000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fa55b6db000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003fb3e00000)
    libz.so.1 => /usr/local/Python-2.7/lib/libz.so.1 (0x00007fa55b5c6000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007fa55b3c3000)

    Alex

     
  • Alex Lai
    Alex Lai
    2013-03-10

    I tried by removing mysql for RedHat rpms and installing mysql for generic linux and rebuild MySQL-python-1.2.4, still no luck. Alex

     
  • Alex Lai
    Alex Lai
    2013-03-11

    Thanks Andy. I will try it tomorrow. I'm guessing this issue is caused by the fact that libmysqlclient.so in mysql-libs- is replaced by MySQL-shared-compat- in MySQL5.6.10.
    Will let you know.
    Alex

     
  • Alex Lai
    Alex Lai
    2013-03-11

    Andy, It worked. Thanks.

    Alex

     
  • zhenglq
    zhenglq
    2013-10-22

    Hi Alex. I need your help, I have same problem. can you tell me the way?

     
  • zhenglq
    zhenglq
    2013-10-22

    vmware machine
    OS: red hat 5.7
    Mysql 5.6.14
    Mysql-python-1.2.4
    Thanks.
    zhenglq