-   Linux - Software (
-   -   Connecting to MySQL (

ksalopek 06-07-2004 02:14 PM

Connecting to MySQL

I am still a newbie at Linux, and I am trying to get some C/C++ code to compile and run that will connect to a MySQL database on a Windows 2000 computer on my network.

I cannot get any code to compile if I do any more than:

#include "/usr/local/mysql/mysql.h"
MYSQL *test;

if i try to do mysql_connect() i get the error 'mysql_connect undeclared'

I use the compile command:
gcc main.o main.cpp -I/usr/local/mysql/include -L/usr/local/mysql/lib -lmysqlclient

the include and library files for mysql are in the /usr/local/mysql directory

I have not actually installed mysql on the linux box since I am trying to connect to the windows box.

Any suggestions?

marghorp 06-07-2004 02:47 PM

read the errors. connection undeclared. Shouldn't there be any parameters for mysql connecting?

ksalopek 06-07-2004 05:16 PM

Sorry, i forgot to say that I did pass everything that was in the tutorial (changed to meet my system specs of course), and I still go the error

btmiller 06-07-2004 06:14 PM

Check the pathname to that header file -- on my system it's located at /usr/local/mysql/include/mysql/mysql.h. You're probably better off with something like:

#include <mysql/mysql.h>

And then your include path looks correct.

ksalopek 06-11-2004 10:05 AM

I looked and the actual file mysql.h is at /root/mysql/include so I think I have it going to the right place.

Unless it cannot be in root or something like that.

ksalopek 06-11-2004 10:07 AM

I realize that I have a different path other than /root/mysql/include , but i have tried both ways with no luck.

From a friend, I was told that if i install the RPM for mysql it should make a folder in the /usr/local/include, but I have not been able to get it to do that either!

All times are GMT -5. The time now is 01:45 PM.