Menu

Question about compiling MySQLdb

Help
2006-07-07
2012-09-19
  • Clifford Hill

    Clifford Hill - 2006-07-07

    Related to the problem which is described in the "_mysql.so: undefined symbol: __pure_virtual" thread, I am attempting to build MySQLdb from source, on a Red Hat Enterprise Linux 4 server. Stats:

    • Red Hat Enterprise Linux 4
    • MySQL 5.0.22, RPM install, including devel package.
    • MySQLdb 1.2.1_p2
    • Python 2.3.4, compiled with GCC 3.4.2
    • GCC 3.4.3 is installed on the system

    Important notes:
    1. Upgrading Python or GCC is flat out of the question.
    2. when I compile, I get the "undefined symbol: __pure_virtual" error.
    3. I have added the following to site.cfg in an effort to resolve the problem:
    [compiler]
    library_dirs: /usr/lib/mysql
    include_dirs: /usr/include/mysql
    libraries: gcc
    mysqlclient
    z
    crypt
    nsl
    m
    c
    nss_files
    nss_dns
    resolv
    c
    nss_files
    nss_dns
    resolv

    This has had zero success. I have tried to build MySQLdb as an RPM with no success either (there's something wierd about making an RPM on that server I haven't tracked down yet).

    My current line of thought is maybe I can build an RPM by installing linux on a second system, which can use Python 2.3 (since once again, upgrading to python 2.4 is flat out not possible). I hope that if I can get the RPM built, and install it on the production RHEL4 server, that it will work... but I am not certain.

    Does anyone have any tips/pointers as to what I might be able to do... finding a second system I can install Linux onto is currently a hang-up for me, but I'm still looking. Or can (and I know this is asking much) someone make an RPM I could potentially use to get this done?

     
    • Clifford Hill

      Clifford Hill - 2006-07-10

      Ok, got it to work. The problem was most definitely an issue where the MySQL RPM's from mysql.com are built with a different compiler than I was trying to build MySQL-python with.

      To get this to work on a Red Hat Enterprise Linux 4 system, I installed a "vanilla" version of Fedora Core 3 (which is pretty close to what the RHEL4 has for versions of software) on a secondary "build" system. My RHEL4 server is a production server, and is not used for compiling, so I have to use a "proxy" build server to make it work. I also had to install the Perl DBI library (necessary to install the MySQL RPMs you build). I downloaded the MySQL source RPM from mysql.com, and then built the MySQL 5.0.22 RPMs from the source RPM (it makes 11 separate RPMs).

      I installed the MySQL-server, MySQL-client, MySQL-Max, MySQL-shared, and MySQL-devel RPMs I built onto the Fedora Core 3 system. the Max RPM isn't strictly necessary, but I use some of the features it provides.

      To be able to build the MySQL-python 1.2.1_p2 rpm, you must copy the HISTORY text file to CHANGES-1.2.1, and also include the CHANGES-1.2.1 filename in the Manifest and Manifest.in files in the MySQL-python directory (or else the rpmbuild will fail -- I'm sure there's a way to hack it to work correctly without this, but I haven't looked into it). I then built the MySQL-python rpm with "python setup.py bdist_rpm". I then could install the MySQL-python rpm, and everything worked fine.

      You can test it by going into python on the Fedora Core 3 system, and typing "install MySQLdb" -- no errors will happen.

      Copy the necessary MySQL RPMs (MySQL-server, MySQL-client, MySQL-shared, MySQL-devel, and also MySQL-Max if you want) plus the MySQL-python RPM over to the Red Hat Enterprise Linux server, and install them in order (server, client, Max, shared, devel, python), everything will work as desired.

       
    • Andy Dustman

      Andy Dustman - 2006-07-07

      GCC-3.4.2 and 3.4.3 shouldn't have any ABI compatibility issues.

      Just found this:

      http://dev.mysql.com/doc/refman/5.0/en/linux-x86.html

      """ If you are using gcc 3.0 and above to compile MySQL, you must install the libstdc++v3 library before compiling MySQL; if you don't do this, you get an error about a missing __cxa_pure_virtual symbol during linking. """

      This is not exactly the same error, but it's something else to look at.

       
    • Clifford Hill

      Clifford Hill - 2006-07-07

      OK, just tried to make it on another system, building with RPM. System is a Fedora Core 3 "vanilla" workstation install, and I installed the MySQL 5.0.22 RPMs (plus devel RPM) into it.

      from:
      python setup.py build ; python setup install
      python
      import MySQLdb

      I get the same exact error I did in RHEL4 (undefined symbol: __pure_virtual)

      python setup.py bdist_rpm

      has error, where it "cannot stat CHANGES-1.2.1" (and RPM is not built). Solved by copying HISTORY to CHANGES-1.2.1, and then editing the MANIFEST & MANIFEST.in files to add in the new CHANGES-1.2.1 file.

      RPM, when installed, produces exact same error as above (undefined symbol: __pure_virtual)

      I looked into the libstdc++v3, and found that it was already installed on the system. "libstdc++-3.4.2-6.fc3" is installed in a vanilla FC3 system.

      stats for FC3 system:

      • Fedora Core 3 (vanilla workstation install)
      • gcc-3.4.2-6.fc3
      • Python 2.3.4 [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)]
      • MySQL-server, MySQL-client, MySQL-Max, MySQL-shared-compat, MySQL-devel packages, all version 5.0.22
      • MySQLdb 1.2.1_p2

      Error message from Python:

      >>> import MySQLdb
      Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.3/site-packages/MySQLdb/init.py", line 19, in ?
      import _mysql
      ImportError: /usr/lib/python2.3/site-packages/_mysql.so: undefined symbol: __pure_virtual


       
      • Andy Dustman

        Andy Dustman - 2006-07-07

        Do you have libstdc++-devel installed? Also you need python-devel and a couple others listed in README.

         
    • Clifford Hill

      Clifford Hill - 2006-07-07

      Besides the above, these are installed as well:

      • python-devel-2.3.4-11
      • libstdc++-devel-3.4.2-6.fc3
      • zlib-1.2.1.2-1
      • zlib-devel-1.2.1.2-1
      • openssl-0.9.7a-40
      • openssl-devel-0.9.7a-40
       
    • Clifford Hill

      Clifford Hill - 2006-07-07

      Well... I'm attempting a compile of MySQL on the Fedora Core 3 system, to see if there is some wierd problem with MySQL being compiled with a different compiler than what I am trying to build the MySQL-python with. It is a complete shot in the dark, but I really am at quite a loss as to what is wrong here.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.