How to compile c program using macintosh gcc
I have a sample code I am trying to compile using gcc 4.0.0 on my Macintosh. How would I compile this. I have tried various attempts yet I have not succeded. Please help. Thank you.
#include <stdio.h>
#include <stdlib.h>
#include "my_sys.h"
#include "mysql.h"
static char *opt_host_name = NULL; // SERVER HOST (DEFAULT=LOCALHOST)
static char *opt_user_name = NULL; // USERNAME (DEFAULT=LOGIN NAME)
static char *opt_password = NULL; // PASSWORD (DEFAULT=NONE)
static unsigned int opt_port_num = 0; // PORT NUMBER (USE BUILT-IN VALUE)
static char *opt_socket_name = NULL; // SOCKET NAME (USE BUILT-IN VALUE)
static char *opt_db_name = NULL; // DATABASE NAME (DEFAULT=NONE)
static unsigned int opt_flags = 0; // CONNECTION FLAGS (NONE)
static MYSQL *conn; // POINTER TO CONNECTION HANDLER
int main( int argc, char *argv[] )
{
//--------------------------------------//
// INIT CONNECTION HANDLER
conn = mysql_init(NULL);
if( conn == NULL )
{
fprintf( stderr, "mysql_init() failed (probably out of memory)\n");
exit(1);
}
//--------------------------------------//
// CONNECT TO SERVER
if( mysql_real_connect( conn, opt_host_name, opt_user_name, opt_password, opt_db_name, opt_port_num, opt_socket_name, opt_flags) == NULL)
{
fprintf( stderr, "mysql_real_connect() failed\n");
mysql_close( conn );
}
//--------------------------------------//
// DISCONNECT FORM SERVER
mysql_close(conn);
exit(0);
}
Subject
Views
Written By
Posted
How to compile c program using macintosh gcc
684
November 03, 2005 12:29PM
444
November 04, 2005 07:46AM
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.