First off, I apologize for the fact that I'm not more versed in the inner
workings of GCC and linking libraries and etc, I'm a web developer and I'm
just using C to try to cut down on some speed problems.

This is my little test program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mysql.h"

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

void exiterr(int exitcode) {
   fprintf( stderr, "%s\n", mysql_error(&mysql) );
}

int main( int argc, char *argv[] ) {
   uint i = 0;

   if(!(mysql_connect(&mysql,"localhost","root","password")))
       exiterr(1);

   if (mysql_select_db(&mysql,"hallow"))
       exiterr(2);

   if(mysql_query(&mysql,"SELECT * FROM sections"))
       exiterr(3);

   if(!(res = mysql_store_result(&mysql)))
       exiterr(4);

   while((row = mysql_fetch_row(res))) {
       for(i=0; i < mysql_num_fields(res); i++)
           printf("%s|",row[i]);
       printf("<br>");
   }

   mysql_free_result(res);
   mysql_close(&mysql);
   return 0;
}

and I'm attempting to compile it with this command:
gcc -I/usr/include concept.c -L/usr/lib/mysql -lmysqlclient -lm -o concept
-lz

I'm quite certain that the header files are in /usr/include.  And, what I
assume to be the libraries are in /usr/lib/mysql. (libdbug.a,libmygcc.a,
libmysql.imp, etc...)

This is the error I get when trying to compile:
/usr/bin/ld: Undefined symbols:
_mysql_connect
collect2: ld returned 1 exit status

Any thoughts on why this might be happening?  Is there any other information
that I can provide which will help to determine whats wrong?

Thanks in advance for the help,
Tyler McMullen

Reply via email to