mysql.h issue

Sven Eschenberg eschenb@cs.uni-frankfurt.de
Sun Apr 30 14:18:00 GMT 2006


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



More information about the Gcc-help mailing list