public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* mysql.h issue
@ 2006-04-30 14:14 Edward Hotchkiss
  2006-04-30 14:18 ` Sven Eschenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Edward Hotchkiss @ 2006-04-30 14:14 UTC (permalink / raw)
  To: gcc-help


When I "make -f MAKE" using the following make file, I Get this error: 

thing.c:28:19: error: mysql.h: No such file or directory
thing.c:49: error: syntax error before '*' token
thing.c:49: warning: data definition has no type or storage class
thing.c: In function 'mysql_connect':
thing.c:134: warning: assignment makes pointer from integer without a
cast
make: *** [thing.o] Error 1

When I run "locate mysql.h"
It returns /usr/include/mysql/mysql.h

Any ideas why I get this error?

- edward 



# MAKE
CC = gcc
INCLUDES = -P/usr/include/mysql/mysql.h
LIBS = -L/usr/local/lib/mysql -lmysqlclient

all: thing

thing: thing.o
	$(CC) -o thing thing.o $(LIBS)

clean:
	rm -f thing.o



/*
thing.c
- WebServer Monitor w/ MySQL logging
- 04/29/06
------------------------------------
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <mysql.h>

// default port to start with
#define DEF_START_PORT  1

// default port to end with
#define DEF_STOP_PORT 65000

// Program Version
#define VERSION 0

// Author
#define AUTHOR "e2"

// MySQL Connection data
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASS "5gtswedfgbc06"
#define MYSQL_DATABASE "thing"

// MySQL Connection Handle
MYSQL *conn;

struct sockaddr_in addr;
struct hostent *rh;
struct servent *rp;

int sock, i;

// Pointers to the start and stop ports
int start_ptr, stop_ptr;

// Show the user proper program usage
int Usage(char *ARG);

// Connection/Port
int CONNECTION(int port);
     
// Iterate through ports, check ports for validity                
int main(int argc, char *argv[])
{

	if (argc != 4)
		Usage(argv[0]);
		start_ptr = atoi(argv[2]);
		stop_ptr = atoi(argv[3]);
	if (strcmp(argv[2],"-")==0 && strcmp(argv[3],"-")==0){
		start_ptr = DEF_START_PORT;
		stop_ptr = DEF_STOP_PORT;
	}
		
	if ( start_ptr > stop_ptr){
		fprintf(stderr,"Error, <Star-Port> Can't Be Greater Than
<Stop-Port>.-\n");
		Usage(argv[0]);
		exit(1);
	}
	// Host does not exist
	if ((rh=gethostbyname(argv[1])) == NULL) {		
		fprintf(stderr,"Can't Resolve Host %s .-\n",argv[1]);
		Usage(argv[0]);
		exit(1);
	}
	// Scan title
	printf("Scanning Host %s From %d TCP Port To %d .-\n", argv[1],
start_ptr, stop_ptr);
	// Iterate through ports
	for (i=start_ptr; i <= stop_ptr; i++)
	{
		if (CONNECTION(i)==0)
		{
			rp = getservbyport(htons(i), "tcp");
			printf("Port %d Is Open !!! <%s>
ServicE.-\n",i,(rp == NULL)?"Uknown":rp->s_name);
		}
	close(sock);
	}
// Exit
return 0;
}

// Try and connect to a port
int CONNECTION(int port)
{
	if ((sock=socket(AF_INET, SOCK_STREAM, 0)) == -1){
		perror("SockeT");
		exit(1);
	}      
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	addr.sin_addr = *((struct in_addr *)rh->h_addr);
	if ((connect(sock,(struct sockaddr *) &addr, sizeof(addr))) ==
0)
		// Port is open
		return 0;
	else
		// Port is close
		return 1;
}

// Invalid usage, display usage information
int Usage(char *ARG) 
{
	fprintf(stderr,"\nUsage: %s <Remote-Host> <Start-Port> <Stop
Port>\n\n", ARG);
	exit(1);
}

// Connect to a MySQL Server
int mysql_connect(int argc, char *argv[])
{
	conn = mysql_init (NULL);
	mysql_real_connect (
		conn,
		// Connect data       
		MYSQL_HOST,
		MYSQL_USER,
		MYSQL_PASS,
		MYSQL_DATABASE,
		// Port
		0,   
		// Socket, use default          
		NULL,
		// Flags, None
		0
	);
};

// Close connection to a mysql server
int mysql_disconnect() 
{
	mysql_close(conn);
}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mysql.h issue
  2006-04-30 14:14 mysql.h issue Edward Hotchkiss
@ 2006-04-30 14:18 ` Sven Eschenberg
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Eschenberg @ 2006-04-30 14:18 UTC (permalink / raw)
  To: Edward Hotchkiss; +Cc: gcc-help

I assume, that:

#include <mysql.h>

should read

#include <mysql/mysql.h>

Since it is in a subdir ...

Regards

-Sven

Edward Hotchkiss wrote:

>When I "make -f MAKE" using the following make file, I Get this error: 
>
>thing.c:28:19: error: mysql.h: No such file or directory
>thing.c:49: error: syntax error before '*' token
>thing.c:49: warning: data definition has no type or storage class
>thing.c: In function 'mysql_connect':
>thing.c:134: warning: assignment makes pointer from integer without a
>cast
>make: *** [thing.o] Error 1
>
>When I run "locate mysql.h"
>It returns /usr/include/mysql/mysql.h
>
>Any ideas why I get this error?
>
>- edward 
>
>
>
># MAKE
>CC = gcc
>INCLUDES = -P/usr/include/mysql/mysql.h
>LIBS = -L/usr/local/lib/mysql -lmysqlclient
>
>all: thing
>
>thing: thing.o
>	$(CC) -o thing thing.o $(LIBS)
>
>clean:
>	rm -f thing.o
>
>
>
>/*
>thing.c
>- WebServer Monitor w/ MySQL logging
>- 04/29/06
>------------------------------------
>*/
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <errno.h>
>#include <unistd.h>
>#include <arpa/inet.h>
>#include <sys/types.h>
>#include <sys/socket.h>
>#include <netinet/tcp.h>
>#include <netinet/ip.h>
>#include <netinet/in.h>
>#include <netdb.h>
>#include <unistd.h>
>#include <mysql.h>
>
>// default port to start with
>#define DEF_START_PORT  1
>
>// default port to end with
>#define DEF_STOP_PORT 65000
>
>// Program Version
>#define VERSION 0
>
>// Author
>#define AUTHOR "e2"
>
>// MySQL Connection data
>#define MYSQL_HOST "localhost"
>#define MYSQL_USER "root"
>#define MYSQL_PASS "5gtswedfgbc06"
>#define MYSQL_DATABASE "thing"
>
>// MySQL Connection Handle
>MYSQL *conn;
>
>struct sockaddr_in addr;
>struct hostent *rh;
>struct servent *rp;
>
>int sock, i;
>
>// Pointers to the start and stop ports
>int start_ptr, stop_ptr;
>
>// Show the user proper program usage
>int Usage(char *ARG);
>
>// Connection/Port
>int CONNECTION(int port);
>     
>// Iterate through ports, check ports for validity                
>int main(int argc, char *argv[])
>{
>
>	if (argc != 4)
>		Usage(argv[0]);
>		start_ptr = atoi(argv[2]);
>		stop_ptr = atoi(argv[3]);
>	if (strcmp(argv[2],"-")==0 && strcmp(argv[3],"-")==0){
>		start_ptr = DEF_START_PORT;
>		stop_ptr = DEF_STOP_PORT;
>	}
>		
>	if ( start_ptr > stop_ptr){
>		fprintf(stderr,"Error, <Star-Port> Can't Be Greater Than
><Stop-Port>.-\n");
>		Usage(argv[0]);
>		exit(1);
>	}
>	// Host does not exist
>	if ((rh=gethostbyname(argv[1])) == NULL) {		
>		fprintf(stderr,"Can't Resolve Host %s .-\n",argv[1]);
>		Usage(argv[0]);
>		exit(1);
>	}
>	// Scan title
>	printf("Scanning Host %s From %d TCP Port To %d .-\n", argv[1],
>start_ptr, stop_ptr);
>	// Iterate through ports
>	for (i=start_ptr; i <= stop_ptr; i++)
>	{
>		if (CONNECTION(i)==0)
>		{
>			rp = getservbyport(htons(i), "tcp");
>			printf("Port %d Is Open !!! <%s>
>ServicE.-\n",i,(rp == NULL)?"Uknown":rp->s_name);
>		}
>	close(sock);
>	}
>// Exit
>return 0;
>}
>
>// Try and connect to a port
>int CONNECTION(int port)
>{
>	if ((sock=socket(AF_INET, SOCK_STREAM, 0)) == -1){
>		perror("SockeT");
>		exit(1);
>	}      
>	addr.sin_family = AF_INET;
>	addr.sin_port = htons(port);
>	addr.sin_addr = *((struct in_addr *)rh->h_addr);
>	if ((connect(sock,(struct sockaddr *) &addr, sizeof(addr))) ==
>0)
>		// Port is open
>		return 0;
>	else
>		// Port is close
>		return 1;
>}
>
>// Invalid usage, display usage information
>int Usage(char *ARG) 
>{
>	fprintf(stderr,"\nUsage: %s <Remote-Host> <Start-Port> <Stop
>Port>\n\n", ARG);
>	exit(1);
>}
>
>// Connect to a MySQL Server
>int mysql_connect(int argc, char *argv[])
>{
>	conn = mysql_init (NULL);
>	mysql_real_connect (
>		conn,
>		// Connect data       
>		MYSQL_HOST,
>		MYSQL_USER,
>		MYSQL_PASS,
>		MYSQL_DATABASE,
>		// Port
>		0,   
>		// Socket, use default          
>		NULL,
>		// Flags, None
>		0
>	);
>};
>
>// Close connection to a mysql server
>int mysql_disconnect() 
>{
>	mysql_close(conn);
>}
>
>
>
>  
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mysql.h issue
  2006-04-30 14:42 Edward Hotchkiss
@ 2006-04-30 14:45 ` Sven Eschenberg
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Eschenberg @ 2006-04-30 14:45 UTC (permalink / raw)
  To: Edward Hotchkiss; +Cc: gcc-help

Okay, let's see,

You use -L to set the lib directory ... can you check, if there is a 
file called libmysqlclient.so ?

Or maybe try locating the file ... I don't use mysql, thus I am not 
really aware of it'S libs and includes ...

-Sven


Edward Hotchkiss wrote:

>Ok, I changed mysql/mysql.h. 
>
>Only one error now, "/usr/bin/ld: cannot find -lmysqlclient"
>
>Kind of lost here .
>
>-edward
>  
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* mysql.h issue
@ 2006-04-30 14:42 Edward Hotchkiss
  2006-04-30 14:45 ` Sven Eschenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Edward Hotchkiss @ 2006-04-30 14:42 UTC (permalink / raw)
  To: gcc-help


Ok, I changed mysql/mysql.h. 

Only one error now, "/usr/bin/ld: cannot find -lmysqlclient"

Kind of lost here .

-edward

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-30 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-30 14:14 mysql.h issue Edward Hotchkiss
2006-04-30 14:18 ` Sven Eschenberg
2006-04-30 14:42 Edward Hotchkiss
2006-04-30 14:45 ` Sven Eschenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).