|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Hopefully this is just a really silly question:
I can't figure out where the MySQL library is at! I'm using Linux RH 5.2 & MySQL installed by using the source RPM and doing rpm --rebuild [mysql.rpm]. I've done some quick tests and verified mysqld is working ok. I found the include files: /var/tmp/mysql/usr/include/mysql/mysql.h The test program I wrote: #include <stdio.h> #include <sys/time.h> #include </var/tmp/mysql/usr/include/mysql/mysql.h> void main() { MYSQL_RES *result; MYSQL_ROW row; MYSQL *connection, mysql; int state; mysql_init(&mysql); printf("Done."); } // end void main() I compile using g++: /tmp/cca057881.o: In function `main': /tmp/cca057881.o(.text+0x11): undefined reference to `mysql_init' collect2: ld returned 1 exit status If I compile under gcc I get the same error. I beleive this is because g++/gcc don't know where the libraries are at (and neither do I!) Ideas? Astro |
|
#2
|
|||
|
|||
|
Try changing the third include directive back to #include <mysql.h> and use the -I, -L and -lmysqlclient switches when compiling and linking
gcc -c -I/var/tmp/mysql/usr/include/mysql program.c then gcc -o program program.o -L/var/tmp/mysql/usr/lib/mysql -lmysqlclient ..or wherever the header files and client library are located |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > C/C++ w/MySQL [linux] |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|