List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 21 1999 7:39pm
Subject:Re: Compiler Trouble.
View as plain text  
At 1:02 PM -0600 3/21/1999, Thomas R. Bedell wrote:
>Hello All,
>This is probably pretty dumb but...
>Does anybody see a problem with the following code????
>/* Establish Connection to MySQL Server */
>#include "mysql.h"
>#include <stdio.h>
>#include <stdlib.h>
>MYSQL mysql;
>   mysql_init(&mysql);
>  /* my prog here */
>   return 0;
>When I try to comple I get...
>[trbedell@oscar c]# gcc -o connect mysql.c
>/tmp/cca034371.o: In function `main':
>/tmp/cca034371.o(.text+0x9): undefined reference to `mysql_init'
>[trbedell@oscar c]#
>USING: Redhat 5.1, MySQL 3_22_20a, (I have installed  Bench, Client and
>Devel packages also) and glibc-2_0_7-19.

1) You need to link withthe MySQL client library.  Add -lmysqlclient to
your command.
2) If that library isn't installed in some directory that your linker
searches by default, add -L/path/to/directory before the -lmysqlclient
argument.  Otherwise it won't find the library.

Paul DuBois, paul@stripped
Northern League Chronicles:
Compiler Trouble.Thomas R. Bedell21 Mar
  • Re: Compiler Trouble.Fraser MacKenzie21 Mar
  • Re: Compiler Trouble.Paul DuBois21 Mar
  • Compiler Trouble.sinisa21 Mar