Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing A C Client under cygwin

Status
Not open for further replies.

horstneuhaeuser

Programmer
Joined
Jun 15, 2004
Messages
1
Location
DE
Hi,

I have trouble writing a C Client under Windows XP (cygwin
actually). I have narrowed it down to just a few lines of code. This code works fine on my linux box, but in cygwin I get really strange results (core dumped).

Here is the code:
#include <stdio.h>
#include <mysql.h>


int main()
{
MYSQL mysql;
MYSQL_RES* result;
MYSQL_ROW row;
unsigned int i;

mysql_init(&mysql);
if (! mysql_real_connect(&mysql, "server", "user", "", "database", 0, NULL, 0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql));
}

mysql_query(&mysql, "SELECT * FROM name");
result = mysql_use_result(&mysql);

while((row = mysql_fetch_row(result)))
{
for(i = 0; row; i++)
{
printf("i %d row %s\n", i, row);
}
printf("\n");
}

if (! mysql_eof(result))
{
fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
}

mysql_close(&mysql);
}

I just installed MySQL on Windows, everything else seems fine, I can work with the database using the mysql client.

Compiling and linking seem to work. I use /cygdrive/c/mysql/include/mysql.h and /cygdrive/c/mysql/lib/opt/libmySQL.lib. I copied libmySQL.dll into the windows/system32 directory.

I was reading, that in most cases like this, the problem
might be that a wrong library/header file is used. I used the one from inside the MySQL 4.0.20 packake for Windows.

btw, something similar happens on my Mac OSX 10.2 !

Anyone has any idea ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top