#128 build failures due to missing or wrong mysql_config info

MySQLdb-1.2
closed
MySQLdb (285)
5
2012-09-19
2005-02-22
Anonymous
No

My compile on FC3 fails for 1.2.0 (1.0.1 works fine), with
errors about it not finding files (I do have mysql-devel
installed). The gcc command that runs as part of the
script didn't seem to have any lib dirs defined:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -
Wall -Wstrict-prototypes -fPIC -I/usr/local/python-
2.4/include/python2.4 -c _mysql.c -o build/temp.linux-
i686-2.4/_mysql.o -I'/usr/include/mysql'

So I put a simple print statment into the setup.py file at
around line 77 to echo what it thinks the libdirs are.
After re-running the config script, it shows this:

lib_dirs=[]

So - it seems there is a problem with the scripts ability
to gather the proper library information to compile the
module.

Discussion

  • Andy Dustman

    Andy Dustman - 2005-02-22

    Logged In: YES
    user_id=71372

    When you submitted this bug, it said right at the top:

    You MUST include the following information in your report:
    1) Version numbers for MySQLdb, MySQL, Python.

    You have neglected to include your MySQL version.
    Additionally you should state whether or not you are using
    FC3 packages or mysql.com packages.

    Most likely the problem is with an older version of
    mysql_config not supplying the requested value. However, I
    still need the version number in order to pin down where
    this is happening.

     
  • Andy Dustman

    Andy Dustman - 2005-02-22

    Logged In: YES
    user_id=71372

    Another thing that will help: Paste in the complete output
    of the mysql_config command. That will have your version as
    well.

     
  • Andy Dustman

    Andy Dustman - 2005-02-22

    Logged In: YES
    user_id=71372

    I'll add here that I have had a couple other reports about
    problems relating to mysql_config, which I will summarize
    briefly:

    Windows versions of MySQL do not include mysql_config. This
    was known to me prior to 1.2.0 and so there is a special
    configuration for Windows. If this configuration does not
    work without modifications for the standard MySQL and
    Python packages
    *, post your modifications here.

    I had a report from a Solaris user that mysql_config
    included an incorrect compiler flag for his platform (-m64).
    If you find something like this happening, you can work
    around it by adding a line like this somewhere before the
    call to setup():

    extra_compile_args.remove('-m64')
    

    I had a report from a Slackware user using an old-ish
    version of MySQL-4.0 that mysql_config for that version did
    not have an --include option, which caused the build to
    file. That can be worked around with something like this:

    include_dirs.append("/usr/include/mysql")
    

    However, I believe that if you have an UNIX or Linux version
    of MySQL (either 4.0 or 4.1) that is reasonably up-to-date,
    i.e. released within the last few months, that you should
    have no issues at all. I am less certain about 3.23, since I
    don't really know if it has mysql_config or not.

    Another alternative is to use 1.0.1, or copy the relevant
    portion of setup.py for your platform into setup.py.

    Yet another thing that I think will work is to filter out
    any empty lists from the arguments. Then those values could
    be specified in setup.cfg instead. This is probably easier
    for packagers than patching setup.py.

     
  • Andy Dustman

    Andy Dustman - 2005-02-23

    Logged In: YES
    user_id=71372

    There was a report (bug #1150064) about getting -lm] in the
    link line (note the bracket). I am pretty certain this is
    due to mysql_config for that version (3.23.58) not
    supporting some option that was requested by setup.py. setup
    filters the results in most cases, so for libraries it would
    remove anything not starting with -l. However, when you run
    mysql_config with no options or there is an error, you get
    all the options, with the individual sections inside
    brackets. That's what's happening here. The mysql_config
    output will reveal (by omission) which option is causing the
    problem.

    In setup.py, there is a very simple config() function:

    def config(what):
        from os import popen
        return popen("mysql_config --%s" %
    

    what).read().strip().split()

    The problem is, it needs to explicitly close the pipe and
    look at the exit code. If it is non-zero, it should return
    an empty list.:

    def config(what):
        from os import popen
        f = popen("mysql_config --%s" % what)
        data = f.read().strip().split()
        if f.close(): data = []
        return data
    

    I don't think this will completely solve all the problems,
    but it's a start.

     
  • Andy Dustman

    Andy Dustman - 2005-02-27

    Logged In: YES
    user_id=71372

    In the Solaris case, it turned out the bad compiler flag was
    actually right; user had downloaded the wrong version of MySQL.

    The latest CVS version of setup.py has the previously
    described fix.

     
  • Nobody/Anonymous

    Logged In: NO

    The problem with this particular gcc call is the single
    quotes around the -I arguement '/usr/include/mysql' which is
    what is return mysql_config verbatim. The quotes need to be
    stripped off.

     
  • Nobody/Anonymous

    Logged In: NO

    Here's the output of mysql_config on Fedora Core 1 (and
    probably 2 and 3):

    Usage: /usr/bin/mysql_config [OPTIONS]
    Options:
    --cflags [-I'/usr/include/mysql']
    --libs [-L'/usr/lib/mysql' -lmysqlclient
    -lz -lcrypt -lnsl -lm]

    --socket [/var/lib/mysql/mysql.sock]
    --port [3306]
    --version [3.23.58]

    The quotes in cflags need to be stripped in extra_compile_args.
    library_dirs is not getting set (it's []).
    The -lm is ending up as -lm] in the second gcc call to build
    the libraries causing a library not found error -lm].

    Although the rpm builds ok with (as far as I can tell) the
    setup.py complains at the end the there are no rpm files [].

    /python2.3 setup.py bdist_rpm --python=/usr/bin/python2.3

     
  • Andy Dustman

    Andy Dustman - 2005-04-10

    Logged In: YES
    user_id=71372

    All the known issues should be fixed in CVS and 1.2.1c1

     
  • Nobody/Anonymous

    Logged In: NO

    Hi.

    I'm trying to build 'MySQL-python-1.2.1c1' on my Linux FC2:

    [ ]# export PATH=$PATH:/usr/local/mysql/bin/
    [ ]# export mysqlclient=mysqlclient_r
    [ ]# python setup.py clean
    [ ]# python setup.py build
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.3
    copying _mysql_exceptions.py -> build/lib.linux-i686-2.3
    creating build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/init.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/converters.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/connections.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/sets.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/stringtimes.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/mxdatetimes.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/pytimes.py -> build/lib.linux-i686-2.3/MySQLdb
    creating build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/init.py ->
    build/lib.linux-i686-2.3/MySQLdb/consta nts
    copying MySQLdb/constants/CR.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py ->
    build/lib.linux-i686-2.3/MySQLdb/cons tants
    copying MySQLdb/constants/ER.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py ->
    build/lib.linux-i686-2.3/MySQLdb/constan ts
    copying MySQLdb/constants/CLIENT.py ->
    build/lib.linux-i686-2.3/MySQLdb/constant s
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-i686-2.3
    gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
    -march=i386 -mcpu=i686 - D_GNU_SOURCE -fPIC -fPIC
    -I/usr/include/python2.3 -c _mysql.c -o build/temp.linu
    x-i686-2.3/_mysql.o -I'/usr/include/mysql'
    _mysql.c:41:19: mysql.h: No such file or directory


    I don't understand why I get this error message, since I
    usually build
    MySQL+C programs
    by using:
    gcc -o myprogram -I'/usr/local/mysql/include/mysql'
    -L'/usr/local/mysql/lib/mysql' -lmysqlclient -lz -lcrypt
    -lnsl -lm
    myprogram.c

    My server configuration:

    [ ]# /usr/local/mysql/bin/mysql_config
    --cflags [-I'/usr/local/mysql/include/mysql']
    --libs [-L'/usr/local/mysql/lib/mysql'
    -lmysqlclient
    -lz -lcrypt -lnsl -lm]

    --socket [/tmp/mysql.sock]
    --port [3306]
    --version [3.23.58]


    [ ]# find . -name "mysql.h"
    ./usr/src/php-4.3.10/ext/mysql/libmysql/mysql.h
    ./usr/src/mysql-3.23.58/include/mysql.h
    ./usr/src/mysql-4.1.9/include/mysql.h
    ./usr/include/mysql/mysql.h
    ./usr/local/mysql/include/mysql/mysql.h


    [ ]# locate libmysqlclient
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.a
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so.10
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so.10.0.0
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.lai
    /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.la
    /usr/src/mysql-3.23.58/libmysql/libmysqlclient.la
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.a
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so.14
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.lai
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so.14.0.0
    /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.la
    /usr/src/mysql-4.1.9/libmysql/libmysqlclient.la
    /usr/local/mysql/lib/mysql/libmysqlclient.la
    /usr/local/mysql/lib/mysql/libmysqlclient.so.10.0.0
    /usr/local/mysql/lib/mysql/libmysqlclient.so
    /usr/local/mysql/lib/mysql/libmysqlclient.a
    /usr/local/mysql/lib/mysql/libmysqlclient.so.10


    python setup.py build
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.3
    copying _mysql_exceptions.py -> build/lib.linux-i686-2.3
    creating build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/init.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/converters.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/connections.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/sets.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/stringtimes.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/mxdatetimes.py ->
    build/lib.linux-i686-2.3/MySQLdb
    copying MySQLdb/pytimes.py -> build/lib.linux-i686-2.3/MySQLdb
    creating build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/init.py ->
    build/lib.linux-i686-2.3/MySQLdb/consta nts
    copying MySQLdb/constants/CR.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py ->
    build/lib.linux-i686-2.3/MySQLdb/cons tants
    copying MySQLdb/constants/ER.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py ->
    build/lib.linux-i686-2.3/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py ->
    build/lib.linux-i686-2.3/MySQLdb/constan ts
    copying MySQLdb/constants/CLIENT.py ->
    build/lib.linux-i686-2.3/MySQLdb/constant s
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-i686-2.3
    gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
    -march=i386 -mcpu=i686 - D_GNU_SOURCE -fPIC -fPIC
    -I/usr/include/python2.3 -c _mysql.c -o build/temp.linu
    x-i686-2.3/_mysql.o -I'/usr/include/mysql'
    _mysql.c:41:19: mysql.h: No such file or directory

     
  • Andy Dustman

    Andy Dustman - 2005-05-11

    Logged In: YES
    user_id=71372

    Try 1.2.1c2.

     
  • Nobody/Anonymous

    Logged In: NO

    trying with 1.2.1c2:


    []# export PATH=$PATH:/usr/local/mysql/bin/
    []# export mysqlclient=mysqlclient
    []# python setup.py clean
    []# python setup.py build
    running build
    running build_py
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-i686-2.3
    gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
    -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC
    -I/usr/include/python2.3 -c _mysql.c -o
    build/temp.linux-i686-2.3/_mysql.o -I'/usr/include/mysql'
    _mysql.c:41:19: mysql.h: No such file or directory
    _mysql.c:42:26: mysqld_error.h: No such file or directory

    I decided to copy '/usr/include/mysql/.' to the work
    directory:


    []# cp /usr/include/mysql/. .
    []# python setup.py build
    running build
    running build_py
    running build_ext
    building '_mysql' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
    -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC
    -I/usr/include/python2.3 -c _mysql.c -o
    build/temp.linux-i686-2.3/_mysql.o -I'/usr/include/mysql'
    gcc -pthread -shared build/temp.linux-i686-2.3/_mysql.o
    -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
    -lmysqlclient -o build/lib.linux-i686-2.3/_mysql.so
    []# python setup.py install
    running install
    running build
    running build_py
    running build_ext
    running install_lib
    copying build/lib.linux-i686-2.3/_mysql.so ->
    /usr/lib/python2.3/site-packages
    copying build/lib.linux-i686-2.3/MySQLdb/connections.py ->
    /usr/lib/python2.3/site-packages/MySQLdb
    copying build/lib.linux-i686-2.3/MySQLdb/init.py ->
    /usr/lib/python2.3/site-packages/MySQLdb

    OK. It looks I've installed something. I create
    a very simple script ('db.py'):


    !/usr/bin/python

    import MySQLdb

    conn = MySQLdb.connect (host = "localhost",
    user = "root",
    passwd = "xxxxxx",
    db = "test")
    cursor = conn.cursor ()
    cursor.execute ("SELECT VERSION()")
    row = cursor.fetchone ()
    print "server version:", row[0]
    cursor.close ()
    conn.close ()


    But when trying to execute it:


    []# ./db.py
    Traceback (most recent call last):
    File "./db.py", line 7, in ?
    db = "test")
    File
    "/usr/lib/python2.3/site-packages/MySQLdb/init.py", line
    66, in Connect
    return Connection(*args, kwargs)
    File
    "/usr/lib/python2.3/site-packages/MySQLdb/connections.py",
    line 134, in init
    super(Connection, self).init(*args,
    kwargs2)
    _mysql_exceptions.OperationalError: (2002, "Can't connect to
    local MySQL server through socket
    '/var/lib/mysql/mysql.sock' (2)")


    It tries to connect MySQL via '/var/lib/mysql/mysql.sock',
    but on my configuration
    '/tmp/mysql.sock' is the socket (see 'mysql_config' output
    in my last post).

    I've got any idea what's happening. Thank you very much.

     
  • Andy Dustman

    Andy Dustman - 2005-05-11

    Logged In: YES
    user_id=71372

    It looks like you have more than one version of MySQL
    installed. I suspect at runtime you are linking against the
    wrong library, which is causing the socket problem.

    Apparently I will have to definitely remove quotes from the
    paths returned by mysql_config.

     
  • Nobody/Anonymous

    Logged In: NO

    Thank you, Andy. It works with the last candidate.

     
  • Nelson Arzola

    Nelson Arzola - 2005-06-17

    Logged In: YES
    user_id=39023

    In my case, on Mac OS X, with the MySQL installed from the
    www.mysql.com web site (4.1.12-max) the mysql_config
    returned the wrong values.

    -I/usr/local/mysql/include/mysql
    -L/usr/local/mysql/lib/mysql

    should really have been

    -I/usr/local/mysql/include
    -L/usr/local/mysql/lib

    My fix for the problem was to create the following symbolic
    links:

    cd /usr/local/mysql/include
    sudo ln -s mysql .
    cd /usr/local/mysql/lib
    sudo ln -s mysql .
    cd /usr/local/lib
    sudo ln -s /usr/local/mysql/lib/* .

    Then, I used "python2.4 setup.py build" with no problems.

     
  • Nobody/Anonymous

    Logged In: NO

    This information may be pertinent to this open ticket, so
    I'm posting it here instead of creating a new one.
    cbush@neo.rr.com

    I'm using (I realize some of these are quite old version,
    but it is necessary at this time):
    MySQL-python-1.2.1c3
    RedHat Linux 9
    Python 2.2.2
    MySQL-client-4.0.13-0 (from MySQL) - on client
    mysql-server-4.1.10a-2.RHEL4.1 - on remote server

    It isn't overly elegant, but I had to change the way
    "extra_compile_args" was parsed in "setup.py" for my version
    of mysql_config:

    eca = config("cflags")
    extra_compile_args = eca + [ "-I" + dequote(i[2:]) for i
    

    in eca if i.startswith("-I") ]

    That is because this version of mysql_config returns the
    "includes" in "cflags" with single quotes. Here's the
    complete usage output:

    Usage: /usr/bin/mysql_config [OPTIONS]
    Options:
    --cflags [-I'/usr/include/mysql']
    --libs [-L'/usr/lib/mysql' -lmysqlclient
    -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc
    -lnss_files -lnss_dns -lresolv]

    --socket [/var/lib/mysql/mysql.sock]
    --port [3306]
    --version [4.0.13]
    --libmysqld-libs [ -L'/usr/lib/mysql' -lmysqld
    -lpthread -lz -lcrypt -lnsl -lm -lpthread -lc -lnss_files
    -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -lrt]

    Also, in order to get it to install against python 2.2.2,
    there were a few lines of metadata in "setup.py" that needed
    to be removed. Certainly, I doubt that anyone else is using
    such a combination old and new software together, but if
    someone else is dumb enough to try, it is helpful to know
    that the latest build of MySQLdb can be readily made to
    build, install, and run. Doing so is easier than trying to
    work around the "invalid literal" problem with older
    versions of it running against MySQL 4.1 and above.

     
  • Andy Dustman

    Andy Dustman - 2006-02-28

    Logged In: YES
    user_id=71372

    This has been fixed in the current CVS tree.

     

Log in to post a comment.