Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The libmysqlclient functions themselves are unresolved

Status
Not open for further replies.

apatterno

Programmer
Nov 26, 2002
368
US
I admit I'm a newbie to the C backend for MySQL. Anyway, here's my problem: I wrote a simple program to test the client library, but every mysql_* symbol is reported as unresolved.

Also, I might add, I am POSITIVE that libmysqlclient.a exists in /usr/local/mysql/lib.
Code:
#include <mysql.h>
#include <stdio.h>

int main ()
{
  char *mysqlClientInfo;

  mysqlClientInfo = mysql_get_client_info();
  if (mysqlClientInfo != NULL) {
    printf(&quot;%s&quot;,mysqlClientInfo);
    return 0;
  }
  return 1;
}
And I compiled with this command:
Code:
$ gcc -I/usr/local/mysql/include -L/usr/local/mysql/lib -lmysqlclient simplemysqltest.c
simplemysqltest.c: In function `main':
simplemysqltest.c:8: warning: assignment discards qualifiers from pointer target type
/tmp/ccVTW7ra.o: In function `main':
/tmp/ccVTW7ra.o(.text+0x7): undefined reference to `mysql_get_client_info'
collect2: ld returned 1 exit status
Is there something obvious I'm doing wrong?
I'm using MySQL 4.0.13 and gcc 2.95.3.

Please help, thanks in advance.
Will
 
I am sorry; I made a foolish mistake. But for the benefit of the rest of the forum, here's the problem:

I put my command line arguments in the wrong order. I also didn't link with zlib (didn't realize you had to.)

Here's the correct compile command:

[tt]$ gcc -I/usr/local/mysql/include simplemysqltest.c -L/usr/local/mysql/lib -lmysqlclient -lz -o simplemysqltest[/tt]

This was actually the first time I ever tried to invoke gcc from the command line... usually I just leave things up to GNU automake [surprise] And my background's in MS Windows anyway. Eeeek.

I REALLY hope that helps.
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top