Hello Sinisa,
Here it is the line with which I try to compile the program.
----------------------
[nicu@ares QA]$ gcc -g Bug_Report.c -o test.o -L/usr/lib/mysql/libmysqlclient
-I/usr/include/mysql -lmysqlclient -lnsl
/tmp/ccGABNJr.o: In function `main':
/home/nicu/QA/Bug_Report.c:7: undefined reference to `mysql_init'
/home/nicu/QA/Bug_Report.c:8: undefined reference to `mysql_real_connect'
collect2: ld returned 1 exit status
-----------------------
and here it is the code
------------------------
#include <stdio.h>
#include <mysql/mysql.h>
MYSQL mysql;
int main(){
mysql_init(&mysql);
if (!mysql_real_connect(&mysql, "host","user","passwd","rt",0,NULL, 0) )
printf("Failed to connect to database! Error %s ",
mysql_error(&mysql));
mysql_close(&mysql);
return 0;
}
-----------------
What do I do wrong ?
regards
Nicu
Sinisa Milivojevic wrote:
> Nicu Popovici writes:
> > Hello Eric,
> >
> > Ofcourse that my file has such a thing. Otherwise how can it recognizes the
> > MYSQL data type ?
> >
> > I have a line like this
> > MYSQL mysql;
> >
> > But the problem appear at linking time so I do not think that the compilation
> > passes without to know where to find the definitions for all the code that it
> > encounters in my file.
> > I guess that is something with mysql shared libraries ....!!
> >
> > Regards,
> > Nicu
>
> Hi!
>
> For some reason libmysqlclient was not linked in.
>
> Check out that it is located in one of directories pointed to by -L
> directives.
>
> If it is there, then it is linker bug. In that case provide a full
> pathname of that lib in linking command.
>
> Regards,
>
> Sinisa
>
> ____ __ _____ _____ ___ == MySQL AB
> /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic
> /*/ /*/ /*/ \*\_ |*| |*||*| mailto:[EMAIL PROTECTED]
> /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaca, Cyprus
> /*/ /*/ /*/\*\_/*/ \*\_/*/ |*|____
> ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^
> /*/ \*\ Developers Team
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php