Linker problems
Hi!
I'm new to mySQL and trying to build a simple testsoftware in C.
I get the following errors when linking.
test.o:test.c:(.text+0xf): undefined reference to `_mysql_error'
test.o:test.c:(.text+0x8d): undefined reference to `_mysql_connect'
test.o:test.c:(.text+0xa9): undefined reference to `_mysql_close'
collect2: ld returned 1 exit status
I'm using:
Windows XP SP2
mySQL (full installation) version 5 (installed in c:\mysql\)
cygwin gcc version 3.4.4.
I compile and link using the following lines:
gcc -c -Ic:\mysql\include test.c
gcc -o test test.o -Lc:\mysql\lib\opt\ -lmysqlclient
The code is very simple:
/* set up system-wide includes, especially the mysql functions */
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
/* define some variables to use */
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
/* define a more verbose exit function to help debug */
void exiterr(int exitcode)
{
fprintf( stderr, "%s\n", mysql_error(&mysql) );
exit( exitcode );
}
/* the program */
int main()
{
uint i = 0;
/* initiate a connection to the database server */
if (!(mysql_connect(&mysql,"localhost","root","code1")))
exiterr(1);
mysql_close(&mysql);
}
Thanks in advance for any help!
/Mattias
Subject
Views
Written By
Posted
Linker problems
759
October 26, 2005 09:43AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.