Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySql C APIs problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to run this program listed below on a FeeBSD unix server it is giving a a this error message:
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x69): undefined reference to `main'

Can anyone please help me that what's wrong with this i am new to both C and MySql !!

/* client1.c */

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

#define def_host_name NULL /* host to connect to (default = localhost) */
#define def_user_name NULL /* user name (default = your login name) */
#define def_password NULL /* password (default = none) */
#define def_db_name NULL /* database to use (default = none) */

MYSQL *conn; /* pointer to connection handler */

int main (int argc, char *argv[])
{
conn = mysql_init (NULL);
mysql_real_connect (
conn, /* pointer to connection handler */
def_host_name, /* host to connect to */
def_user_name, /* user name */
def_password, /* password */
def_db_name, /* database to use */
0, /* port (use default) */
NULL, /* socket (use default) */
0); /* flags (none) */
mysql_close (conn);
exit (0);
}

 
The code LOOKS ok.(I didn't bother checking the MYSQL calls, as I haven't done THAT in a while.

The error that you are referring to indicates that it can't see the main routine. Usually this is because of just forgetting to put it in(but you have it here), or leaving a quote or comment terminator out prior to it(you apparantly didn't make that mistake either), or having the command line compile wrong.

This should be something like:

cc -lmysql -o client1 client1.c

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top