Mailing List
Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
ODBC - ODBC with the MySQL Connector/ODBC driver
Perl - Perl support for MySQL with DBI and DBD::mysql
MySQL++ - Programming with the C++ API to MySQL
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Executing MySQL Commands From Within C Program

Executing MySQL Commands From Within C Program

2004-03-22       - By Rick Emery

 Back
Reply:     1     2  

See my original post below prior to reading the next 4 lines..

In addition to what I tried below, I tried the following (with this result):
$ ld -lmysqlclient -o myprog myprog.o
ld: warning: cannot find entry symbol _start; defaulting to 08048208
/usr/lib/libmysqlclient.so: undefined reference to `mkstemp64@(protected) '

-- -- Original Message -- --

I am attempting to interface between a simple C program and MySQL, but without luck.

I searched the MySQLforum archives to see if there was info specific to this problem. While there
were other folks who had problems connecting C/C++ to MySQL, none of the issue were similar to this,
that is linking to resolve external name table references.

Here is the actual program:
******* myprog.cc ***********
#include </usr/include/mysql/mysql.h >
int main(void)
{
MYSQL * myptr;
mysql_init(myptr);
return 0;
}

To compile it, I use:
$ gcc -c myprog.cc

To link/load:
$ ld myprog.o -o myprog
ld: warning: cannot find entry symbol _start; defaulting to 08048074
myprog.o: In function `main ':
myprog.o(.text+0xd): undefined reference to `mysql_init

If I try inclusion of the libmysqlclient.so library in the 'ld ' command, I get this:
$ ld -l /usr/lib/libmysqlclient.so myprog.o -o myprog
ld: cannot find -l/usr/lib/libmysqlclient.so

Or, if I compile and link/load in one step, I get this:
$ gcc -o myprog myprog.cc
/tmp/ccJ8uuvK.o: In function `main ':
/tmp/ccJ8uuvK.o(.text+0xd): undefined reference to `mysql_init '
collect2: ld returned 1 exit status

And "ls -l /usr/lib/libmysqlclient* " reveals:
rwxrwxrwx 1 root root 24 Mar 13 19:34 /usr/lib/libmysqlclient.so - >
libmysqlclient.so.12.0.0
lrwxrwxrwx 1 root root 24 Mar 13 19:34 /usr/lib/libmysqlclient.so.10 - >
libmysqlclient.so.10.0.0
-rwxr-xr-x 1 root root 224606 Feb 13 04:25 /usr/lib/libmysqlclient.so.10.0.0
lrwxrwxrwx 1 root root 24 Mar 13 19:34 /usr/lib/libmysqlclient.so.12 - >
libmysqlclient.so.12.0.0
-rwxr-xr-x 1 root root 249972 Feb 13 04:25 /usr/lib/libmysqlclient.so.12.0.0
lrwxrwxrwx 1 root root 26 Mar 13 19:34 /usr/lib/libmysqlclient_r.so - >
libmysqlclient_r.so.12.0.0
lrwxrwxrwx 1 root root 26 Mar 13 19:34 /usr/lib/libmysqlclient_r.so.10 - >
libmysqlclient_r.so.10.0.0
-rwxr-xr-x 1 root root 230560 Feb 13 04:25 /usr/lib/libmysqlclient_r.so.10.0.0
lrwxrwxrwx 1 root root 26 Mar 13 19:34 /usr/lib/libmysqlclient_r.so.12 - >
libmysqlclient_r.so.12.0.0

My setup is Red Hat Linux version 7.0. I used the latest mysql RPM (for Red Hat 7.0) from the mysql
web-site

Where can I go for help on this? If somebody has a suggestion, I 'm all ears. FYI, using MySQL with
PHP works like a charm from the command line and when called from a web-page. So, I know MySQL is
there, ready to do my bidding. I looked through the latestMySQL manual concerning the C/C++ API; no
help.

thanks

rick


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=remery @(protected)


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql @(protected)