#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Cleveland, OH, USA
    Posts
    8
    Rep Power
    0
    Hopefully this is just a really silly question:

    I can't figure out where the MySQL library is at!

    I'm using Linux RH 5.2 & MySQL installed by using the source RPM and doing rpm --rebuild [mysql.rpm]. I've done some quick tests and verified mysqld is working ok.

    I found the include files:

    /var/tmp/mysql/usr/include/mysql/mysql.h

    The test program I wrote:

    #include <stdio.h>
    #include <sys/time.h>
    #include </var/tmp/mysql/usr/include/mysql/mysql.h>

    void main()
    {
    MYSQL_RES *result;
    MYSQL_ROW row;
    MYSQL *connection, mysql;
    int state;

    mysql_init(&mysql);

    printf("Done.");
    } // end void main()

    I compile using g++:
    /tmp/cca057881.o: In function `main':
    /tmp/cca057881.o(.text+0x11): undefined reference to `mysql_init'
    collect2: ld returned 1 exit status

    If I compile under gcc I get the same error. I beleive this is because g++/gcc don't know where the libraries are at (and neither do I!)

    Ideas?

    Astro
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    16
    Try changing the third include directive back to #include <mysql.h> and use the -I, -L and -lmysqlclient switches when compiling and linking

    gcc -c -I/var/tmp/mysql/usr/include/mysql program.c

    then

    gcc -o program program.o -L/var/tmp/mysql/usr/lib/mysql -lmysqlclient

    ..or wherever the header files and client library are located

Similar Threads

  1. Novell Netware authentication w/mysql
    By tnguye31 in forum Development Articles
    Replies: 2
    Last Post: November 3rd, 2003, 09:53 PM
  2. [Linux] Can I create one???
    By coume in forum LDAP Programming
    Replies: 4
    Last Post: August 14th, 2003, 11:42 AM
  3. Not getting results from POST w/mysql
    By groundlevel in forum PHP Development
    Replies: 4
    Last Post: August 12th, 2003, 12:01 PM
  4. Javascript dropdown menu(dynamic) w/MYSQL
    By littlab in forum JavaScript Development
    Replies: 0
    Last Post: August 7th, 2003, 10:23 PM
  5. BDB Table handlers w/MySQL
    By mickalo in forum MySQL Help
    Replies: 2
    Last Post: July 26th, 2001, 09:07 AM

IMN logo majestic logo threadwatch logo seochat tools logo