Linking problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruno

    #1

    Linking problem

    Hello,
    I have the following problem with mysql linking:


    1) 'mysql_config --libs' return (correctly) the following:

    -L/usr/local/mysql/lib -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files
    -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv

    2) compile + link command is based on mysql_config:

    gcc -o t01 -I /usr/local/mysql/include/ -L/usr/local/mysql/lib -lmysqlclient
    -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files
    -lnss_dns -lresolv t01.c -o t01

    my versions are:
    MySQL: 4.0.17
    gcc: 3.3.3
    platform: Linux

    3) and my (very) simple test C file (referenced t01.c in previous gcc
    command):

    #include <stdio.h>
    #include <mysql.h>
    int main( int argc, char *argv[] )
    {
    MYSQL conn;
    mysql_init( &conn );
    //...
    }

    but I received the (arrghhh....) following error:

    /tmp/ccbPFqEt.o(.tex t+0x1e): In function `main':
    : undefined reference to `mysql_init'
    collect2: ld returned 1 exit status


    Thanks for any help.

  • Bruno

    #2
    Re: Linking problem

    It works fine now.
    In fact, it seems the binary distribution I used lack some libraries (static
    and/or shared ?).
    So, I downloaded a source distribution, compile and install it, and it works
    now.


    Bruno wrote:
    [color=blue]
    > Hello,
    > I have the following problem with mysql linking:
    >
    >
    > 1) 'mysql_config --libs' return (correctly) the following:
    >
    > -L/usr/local/mysql/lib -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files
    > -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv
    >
    > 2) compile + link command is based on mysql_config:
    >
    > gcc -o t01 -I /usr/local/mysql/include/ -L/usr/local/mysql/lib
    > -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc
    > -lnss_files -lnss_dns -lresolv t01.c -o t01
    >
    > my versions are:
    > MySQL: 4.0.17
    > gcc: 3.3.3
    > platform: Linux
    >
    > 3) and my (very) simple test C file (referenced t01.c in previous gcc
    > command):
    >
    > #include <stdio.h>
    > #include <mysql.h>
    > int main( int argc, char *argv[] )
    > {
    > MYSQL conn;
    > mysql_init( &conn );
    > //...
    > }
    >
    > but I received the (arrghhh....) following error:
    >
    > /tmp/ccbPFqEt.o(.tex t+0x1e): In function `main':
    > : undefined reference to `mysql_init'
    > collect2: ld returned 1 exit status
    >
    >
    > Thanks for any help.
    >[/color]

    Comment

    Working...