MySQL Forums
Forum List  »  Connector/C (libmysql)

Help Connecting to MySQL using Eclipse for C on Windows
Posted by: William Spence
Date: September 07, 2016 02:33PM

I am a total newbie at using MySQL and programming in C, but I can't actually begin coding because I cannot get my Eclipse C Environment set up right to even build a project. I have installed MySQL Connector, but I don't think that I have set up the libraries and paths correctly to make everything work. Here is the code that I have tried, very simple:

#include <stdio.h>
#include <stdlib.h>
#include <C:\Program Files\MySQL\MySQL Connector.C 6.1\include\mysql.h>

int main(void) {
MYSQL *conn;
char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "database";
conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
}

I have added the following Library Search Paths(-L) under the project properties in the MinGW Linker:

"C:/Program Files/MySQL/MySQL Connector.C 6.1/lib"
"C:/Program Files/MySQL/MySQL Connector.C 6.1/lib/vs12"

I have added the libraries(-l) under the project properties in the MinGW Linker:

C:/Program Files/MySQL/MySQL Connector.C 6.1/lib/libmysql.lib
C:/Program Files/MySQL/MySQL Connector.C 6.1/lib/vs12/mysqlclient.lib

but when I try to build the project, I get the error that ld.exe cannot find either of the libraries I added???

c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/6.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lC:/Program Files/MySQL/MySQL Connector.C 6.1/lib/libmysql.lib
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/6.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lC:/Program Files/MySQL/MySQL Connector.C 6.1/lib/vs12/mysqlclient.lib

I am so frustrated just trying to set this up and want to get to coding, so any insight would be GREATLY appreciated!!! Thanks!

Options: ReplyQuote


Subject
Views
Written By
Posted
Help Connecting to MySQL using Eclipse for C on Windows
757
September 07, 2016 02:33PM


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.