0
votes

I am trying to compile the following:

#include <stdio.h>
#include <stdlib.h>
#include <my_global.h>
#include <mysql.h>


int main(void) {
    puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
    printf("MySQL client version: %s\n", mysql_get_client_info());
return EXIT_SUCCESS;
}

However, Eclipse is giving the following error messaage:

Building target: TestConsole4 Invoking: GCC C Linker gcc -L/usr/include -L/usr/include/mysql -o "TestConsole4" ./src/TestConsole4.o
./src/TestConsole4.o: In function main': /home/hearme/workspace/TestConsole4/Debug/../src/TestConsole4.c:19: undefined reference tomysql_get_client_info' collect2: ld returned 1 exit status make: *** [TestConsole4] Error 1

I have been going around in circles trying to fix this, any ideas?

Thanks

1

1 Answers

3
votes

From the MySQL reference manual:

"MySQL clients must be linked using the -lmysqlclient -lz options in the link command. You may also need to specify a -L option to tell the linker where to find the library. For example, if the library is installed in /usr/local/mysql/lib, use these options in the link command:

-L/usr/local/mysql/lib -lmysqlclient -lz"