Here's the Makefile I used for my simple test program:
CC = gcc
LD = gcc
CFLAGS = -std=c99 -Wall -W -pedantic -g -Ic:/mysql/include -c -o
LDFLAGS = -Lc:/mysql/lib/opt -lmysql -o $(EXEC)
EXEC = wizard_spells.exe
OBJECTS = wizard_spells.o
all: $(OBJECTS) $(LD) $(OBJECTS) $(LDFLAGS)
%.o: %.c $(CC) $(CFLAGS) $@ $<
clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump
I haven't tampered with the mysql libraries at all btw.
Here's the actual test program: #include <mysql.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
static MYSQL m;
void create_chemistry_recipe_table(void);
int main(void) { const char *host = "localhost"; const char *user = "root"; const char *password = "andromeda"; const char *database = "spells";
if(!mysql_init(&m)) { fprintf(stderr, "mysql_init() failed.\n");
return EXIT_FAILURE; }
if(!mysql_real_connect( &m, host, user, password, database, 0, NULL, 0 ) ) { fprintf(stderr, "%s\n", mysql_error(&m));
return EXIT_FAILURE; } else { printf("Connection successful.\n"); }
create_chemistry_recipe_table();
printf("calling mysql_close()\n");
mysql_close(&m);
return EXIT_SUCCESS; }
void create_chemistry_recipe_table(void) { if(mysql_query(&m, "CREATE TABLE chemistry_recipes " "(name VARCHAR(64), primary_components " "VARCHAR(64))") == 0) { printf("Chemistry table successfully created.\n"); } else { printf("Failed to create chemistry recipe table.\n" "Error code: %u\n" "Description: %s\n", mysql_errno(&m), mysql_error(&m)); } }
And, finally, the output: $ ./wizard_spells.exe Connection successful. Failed to create chemistry recipe table. Error code: 1050 Description: Table 'chemistry_recipes' already exists Segmentation fault (core dumped)
Thanks for any replies and I'm sorry if this is off-topic. I thought about if I should post on a MySQL list or on a Cygwin list and I decided to post here in the end.
/ Mikael
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/