Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <006101c4f88e$1b24af50$0300a8c0@mindcooler> From: =?iso-8859-1?Q?Mikael_=C5sberg?= To: "Cygwin List" Subject: Anyone creating programs using the MySQL C api using Cygwin? Date: Wed, 12 Jan 2005 11:04:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Hello, I installed a native windows version of MySQL (4.1.18) and tried to compile a C program using the MySQL C API using GCC (version 3.3.3 cygwin special). The program compiles and links without any errors or warnings (maximum warning level, c99-mode) but segfaults near the end. I haven't been able to reproduce the segfault using linux...so my question is: I am silly thinking I could use a native Windows version of MySQL with Cygwin without any problems? I guess I could use MSVC++, of which I own a legitimate copy, but I am trying to use it as little as possible. 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 #include #include #include 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/