This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Crash of mysql under cygwin with g++ 3.3.1
- From: Fabrice Marchal <fmarchal at inf dot ethz dot ch>
- To: "Gerrit @ cygwin" <cygwin at cygwin dot com>
- Date: Tue, 24 Feb 2004 17:37:25 +0100
- Subject: Re: Crash of mysql under cygwin with g++ 3.3.1
- References: <Pine.LNX.4.44.0311280144210.25293-100000@piz.ethz.ch> <1256769927.20040104213024@familiehaase.de>
Hallo Gerrit,
Thanks for your help. I would like to ask you a few questions:
1) If I use your mysql-4.0.17 libraries, that is if I link my code
against your libmysqlclient.a
then my code works OK. On the other hand, then it requires
cygmysqlclient.dll also: what is
that library exactly? Is it the equivalent of mySQL.dll which is
included in the mysql for windows?
2) I have now identified the bug, or at least what causes it: here is
small example that
crashes when using cygwin-1-5-7.1, MYSQL 4.0.18 and GCC3.3.1 (G++):
#include <mysql.h>
#include <iostream>
using namespace std;
class Connection{
MYSQL* mqlh;
public:
Connection(){
mqlh = mysql_init( NULL );
cout << "OK" << endl;
}
};
int main( int argc, char** args ){
Connection* con = new Connection();
// crashes here
}
As you can see, it seems that something is really wrong. It seems to be
caused by new()
since removing the mysql_init() from the new() call seems to work.
I have to mention that I link only against -lmySQL which is provided in
the mysql for
windows distro. Maybe that is the problem (i.e. it was build from older
cygwin releases)
As I would like to ship a "clean" version, I don't know what to do.
Normally, people
would install mysql-for-win, then install my code plus just the cygwin DLL.
Regards,
Fabrice
Gerrit P. Haase wrote:
Hallo Fabrice,
late reply, sorry.
Your code snippet works for me with the latest Cygwin gcc-3.3.1 and
MySQL 4.0.17 which I compiled today and which is available for testing
here: http://anfaenger.de/cygwin-1.5/mysql/
$ gcc -I/usr/include/mysql \
-o mysql mysql.cpp \
-L/usr/lib/mysql -lmysqlclient \
-L/usr/lib -lstdc++
$ ./mysql
$ g++ -I/usr/include/mysql \
-o mysql mysql.cpp \
-L/usr/lib/mysql -lmysqlclient
$ ./mysql
No problem here.
Am Freitag, 28. November 2003 um 01:46 schriebst du:
I dont know if this is a problem of mysql, g++ or
cygwin but the following simple code keeps crashing with g++3.3.1
Platform: cygwin-1.5.5, mysql 3.23 (and mysql 4.1 as well).
Note that the code does not crash if all the mysql_ calls are
made from inside the "main()" block. GDB reports that the crash occurs
when returning from the Connection() constructor.
The code was working with former g++2.95 under cygwin.
#include "mysql.h"
#include <iostream>
using namespace std;
class Connection{
MYSQL *mysql;
public:
Connection(){
mysql = mysql_init( NULL );
if( mysql == 0 ){
cerr << "failed to init" << endl;
exit(-1); }
mysql_real_connect( mysql, "", "", "", "test", 3306, NULL, 0);
}
};
int main( int argc, char** args ){
Connection con;
}
HTH,
Gerrit
--
========================================================================
Fabrice Marchal http://www.inf.ethz.ch/~marchal
fabrice.marchal@ieee.org marchal@inf.ethz.ch +41-(0)1-632-56-79
ETH Zurich, CoLab Computational Laboratory FAX:+41-(0)1-632-17-03
========================================================================
--
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/