mysql.h not found... why not? [C] [MacOSX]
Posted by: Lynsey Schroeder
Date: March 09, 2012 11:27AM

Hello,

I'm attempting to connect to my MySQL database using a C program, but it isn't making it past the #include <mysql.h> line because it fails the compile when it can't find the header. I'm not sure why it can't find the header, I have it in the same directory as all the other headers (i.e. stdlib.h or stdio.h), which is /usr/include. I put everything from the C Connector into the include, lib, and bin folders within the usr directory.

Can anybody shed some light on this? I'm stuck.

I'm using Mac OSX Lion and xCode.

Here is my program:

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

int main()
{
MYSQL *conn;
//MYSQL_RES *res;
MYSQL_ROW row;

char *server ="localhost";
char *user = "lynseysc";
char *password = "";
char *database = "lynseysc_misc";

conn = mysql_init(NULL);

if(mysql_real_connection(conn, server, user, password, database, 0, NULL, 0))
{
printf("Connected successfully!");
}
else
{
printf("Error connecting.");
}

return 0;
}

Options: ReplyQuote


Subject
Views
Written By
Posted
mysql.h not found... why not? [C] [MacOSX]
4244
March 09, 2012 11:27AM


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.