From: Sasha Pachev Date: May 18 1999 3:00am Subject: Re: mysql_real_connect problem List-Archive: http://lists.mysql.com/mysql/3498 Message-Id: <3740D7B8.2167FA88@direct1.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Yury Bukhman wrote: > > I am trying to create a simple MySQL client program in C. I'm getting a > runtime "segmentation fault" error. I could not figure out why. Please, > help! > > ____ > Here is gdb diagnostic: > (command: gdb programname core) > Program terminated with signal 11, Segmentation fault. > find_solib: Can't read pathname for load map: Input/output error > > #0 0x8049f4d in mysql_real_connect () > > ____ > Here is the relevant part of my program: > > #include > #include "mysql.h" > > int main(){ > MYSQL *mysql; /*server handle*/ > char *host = "localhost"; /*hostname or an IP address*/ > char *user = "guest"; /*user ID*/ > char *passwd = NULL; /*password*/ > char *db = "dom_base"; /*database name*/ > unsigned int port = 0; /*TCP-IP port*/ > char *unix_socket = "/tmp/mysql.sock"; /*UNIX socket for mysql > connection*/ > unsigned int client_flag = 0; > char *query; > MYSQL_RES *result; > MYSQL_ROW row; > > char *id, *method; /*pdb table field values*/ > float resoln, r; /*pdb table field values*/ > > if(mysql_init(mysql)==NULL){ /*initialize server handle*/ > printf("mysql_init failed\n"); > return 1; > } > if(mysql_real_connect(mysql, host, user, passwd, db, port, > unix_socket, client_flag)==NULL){ > (at this statement, program crushes) > > ___ > My compilation command: > gcc -o first first.c -L/export/genie11/yury/mysql/lib -lmysqlclient > -I/export/genie11/yury/mysql/include -W -Wall -g > (exits normally with no warnings) > Try changing passwd to "" ( emply stirng) instead of NULL ( null pointer). -- Sasha Pachev http://www.sashanet.com