Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MySql C APIs problem

MySql C APIs problem

MySql C APIs problem

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);

RE: MySql C APIs problem

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


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close