I can send the truss output of anyone can decipher it!! Regards
Andy On Tue, 2005-01-11 at 13:05 +0000, Andy Ford wrote: > Hi everyone. > > I have been trying to write a simple c program to access a local mySQL > database (with the help of David Logan). With the following code I am > getting the error ... > > Bus Error (core dumped) > > ... when I run my compiled program 'test'. > > [code] > int main(char **args) { > MYSQL_RES *result; > MYSQL_ROW row; > MYSQL *connection, mysql; > int state; > > mysql_init(&mysql); > connection = mysql_real_connect(&mysql, "localhost", "username", > "password", "mydb", 0, NULL, 0); > /* check for a connection error */ > if( connection == NULL ) { > printf(mysql_error(&mysql)); > return 1; > } else { > printf("Everything Cool with the connection\n"); > } > state = mysql_query(connection, "SELECT * from mytable"); > if( state ) { > printf(mysql_error(connection)); > return 1; > } else { > printf("Everything Cool with the query\n"); > } > > mysql_close(connection); > printf("Done.\n"); > } > [/code] > > The actual output is ... > Everything Cool with the connection > Everything Cool with the query > Bus Error (core dumped) > > The 'Bus Error' I have Googled for but can't find a resolution. > > Any ideas? > > Thanks again.. > > Andy > > On Tue, 2005-01-11 at 12:05 +0000, Andy Ford wrote: > > Got it ... > > > > Thanks David > > > > >gcc -m64 test.c -L/usr/local/mysql/lib -lmysqlclient -lsocket -lnsl -lm > > -o test > > > > .. seemed to work > > > > I get a 'Bus Error (core dumped)' when I run it - but that's a problem > > with the code!! > > > > Thanks > > > > Andy > > > > On Tue, 2005-01-11 at 22:23 +1100, Logan, David (SST - Adelaide) wrote: > > > Hi Andy, > > > > > > I resolved the problem by reinstalling a 32bit version of mysql and the > > > DBI worked fine after that. Looks like you are missing a library or 2, > > > try nsl and socket. I think they have all the routines that you need to > > > link against. > > > > > > You may also need an include or 2. All the routines have man pages that > > > reference the libraries and includes required. > > > > > > Regards > > > > > > David Logan > > > Database Administrator > > > HP Managed Services > > > 148 Frome Street, > > > Adelaide 5000 > > > Australia > > > > > > +61 8 8408 4273 - Work > > > +61 417 268 665 - Mobile > > > +61 8 8408 4259 - Fax > > > > > > > > > -----Original Message----- > > > From: Andy Ford [mailto:[EMAIL PROTECTED] > > > Sent: Tuesday, 11 January 2005 9:37 PM > > > To: Logan, David (SST - Adelaide) > > > Cc: mysql@lists.mysql.com > > > Subject: RE: compilation errors in mySQL C app > > > > > > Hi David > > > > > > Yes it is something like you say... > > > > > > >file /usr/local/bin/gcc > > > /usr/local/bin/gcc: ELF 32-bit MSB executable SPARC Version 1, > > > dynamically linked, not stripped > > > > > > >file /usr/local/bin/g++ > > > /usr/local/bin/gcc: ELF 32-bit MSB executable SPARC Version 1, > > > dynamically linked, not stripped > > > > > > >isainfo -kv > > > 64-bit sparcv9 kernel modules > > > > > > I got rid of the ELF issue with the -m64 option but still get the > > > following errors... > > > > > > > gcc -m64 test.c -L/usr/local/mysql/lib -lmysqlclient -o test > > > > > > Undefined first referenced > > > symbol in file > > > getpeername > > > /usr/local/mysql/lib/libmysqlclient.a(viosocket.o) > > > floor > > > /usr/local/mysql/lib/libmysqlclient.a(password.o) > > > socket > > > /usr/local/mysql/lib/libmysqlclient.a(client.o) > > > gethostbyname_r > > > /usr/local/mysql/lib/libmysqlclient.a(client.o) > > > setsockopt > > > /usr/local/mysql/lib/libmysqlclient.a(viosocket.o) > > > getservbyname > > > /usr/local/mysql/lib/libmysqlclient.a(libmysql.o) > > > connect > > > /usr/local/mysql/lib/libmysqlclient.a(client.o) > > > shutdown > > > /usr/local/mysql/lib/libmysqlclient.a(viosocket.o) > > > inet_ntoa > > > /usr/local/mysql/lib/libmysqlclient.a(my_net.o) > > > inet_addr > > > /usr/local/mysql/lib/libmysqlclient.a(client.o) > > > ld: fatal: Symbol referencing errors. No output written to test2 > > > collect2: ld returned 1 exit status > > > > > > Getting there slowly > > > > > > Thanks > > > > > > Andy > > > > > > On Tue, 2005-01-11 at 21:42 +1100, Logan, David (SST - Adelaide) wrote: > > > > Hi Andy, > > > > > > > > Are you using a 64bit option to compile your program (I can't remember > > > > the option on gcc -m64 I think)? Looks like a 64bit mysql library > > > trying > > > > to talk to a 32 bit program. I'm no expert but I had similar problems > > > > when I put a 64bit mysql on one of my Solaris boxen and tried to talk > > > > with a 32 bit perl implementation. > > > > > > > > Regards > > > > > > > > > > > > David Logan > > > > Database Administrator > > > > HP Managed Services > > > > 148 Frome Street, > > > > Adelaide 5000 > > > > Australia > > > > > > > > +61 8 8408 4273 - Work > > > > +61 417 268 665 - Mobile > > > > +61 8 8408 4259 - Fax > > > > > > > > > > > > -----Original Message----- > > > > From: Andy Ford [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, 11 January 2005 8:59 PM > > > > To: mysql@lists.mysql.com > > > > Subject: compilation errors in mySQL C app > > > > > > > > Hi everyone > > > > > > > > I am trying to compile a simple C program to connect to a mySQL > > > database > > > > (on localhost) and run a simple query. > > > > > > > > I am getting the following errors... > > > > > > > > >gcc test.c -L/usr/local/mysql/lib -lmysqlclient -o test > > > > > > > > ld: warning: file /usr/local/mysql/lib/libmysqlclient.a(libmysql.o): > > > > wrong ELF class: ELFCLASS64 > > > > Undefined first referenced > > > > symbol in file > > > > mysql_query /var/tmp//ccpHcO9u.o > > > > mysql_init /var/tmp//ccpHcO9u.o > > > > mysql_close /var/tmp//ccpHcO9u.o > > > > mysql_free_result /var/tmp//ccpHcO9u.o > > > > mysql_num_rows /var/tmp//ccpHcO9u.o > > > > mysql_error /var/tmp//ccpHcO9u.o > > > > mysql_store_result /var/tmp//ccpHcO9u.o > > > > mysql_real_connect /var/tmp//ccpHcO9u.o > > > > mysql_fetch_row /var/tmp//ccpHcO9u.o > > > > > > > > ld: fatal: Symbol referencing errors. No output written to test2 > > > > collect2: ld returned 1 exit status > > > > > > > > Any ideas how I can fix these? > > > > > > > > Thanks > > > > > > > > Andy > > > > -- > > > > perl -e "print qq^bIG VeRN ! ^^qq^#'#Yv#=<D+ ^" > > > > > > > > This e-mail is private and may be confidential and is for the intended > > > > recipient only. If misdirected, please notify us by telephone and > > > > confirm that it has been deleted from your system and any copies > > > > destroyed. If you are not the intended recipient you are strictly > > > > prohibited from using, printing, copying, distributing or > > > disseminating > > > > this e-mail or any information contained in it. We use reasonable > > > > endeavours to virus scan all e-mails leaving the Company but no > > > warranty > > > > is given that this e-mail and any attachments are virus free. You > > > > should undertake your own virus checking. The right to monitor e-mail > > > > communications through our network is reserved by us. > > > > > > > > > > > > > > -- > > perl -e "print qq^bIG VeRN ! ^^qq^#'#Yv#=<D+ ^" > > > -- > perl -e "print qq^bIG VeRN ! ^^qq^#'#Yv#=<D+ ^" > -- > perl -e "print qq^bIG VeRN ! ^^qq^#'#Yv#=<D+ ^" > -- perl -e "print qq^bIG VeRN ! ^^qq^#'#Yv#=<D+ ^" -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]