PDA

View Full Version : mysql link errors



GoRaiders007
12-02-2003, 10:02 PM
I'm compiling/linking a C application and getting link errors. This app has been tested/compiled/linked on mylocal machine and runs fine. The app will loginto my db, peform some queries, and send an email alert to users of my website.

I'm assuming the path to mysql/lib is correct, but I have no access to that directory. Any help is appreciated. (live chat seems to be dead). The errors are as follows...

west48:~/db$ gcc -c -I/usr/local/mysql/include ADSendAlert.c
west48:~/db$ gcc -o ADSendAlert ADSendAlert.o -L/usr/local/mysql/lib -lmysqlclient -lz
ADSendAlert.o: In function `main':
ADSendAlert.o(.text+0xfb): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x10c): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x193): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x1a4): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x1f6): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x207): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x2c9): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x2da): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x327): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x338): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x547): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x55b): undefined reference to `mysql_error'
ADSendAlert.o(.text+0x56c): undefined reference to `mysql_errno'
ADSendAlert.o(.text+0x598): undefined reference to `mysql_num_rows'
collect2: ld returned 1 exit status

wildjokerdesign
12-03-2003, 09:03 AM
Not sure what the program is doing but do know you need MySQL installed first via the SiteManager to use msysql and that the database needs to be on the server. I can't tell but it looks like your errors are coming from the program and not the server right?

To run php with mysql you allso have to install the phpmysl libs so there may be something like that for C also.

If your setup is like others in /usr/local/mysql/lib there is a mysql sym link to /ftp/usr/lib/mysql . Why do you not have access to that directory? You should. How did you install the program on your server? Or are you trying to connect to the database on your server from your local machine? Sorry for all the questions but not real clear what you are trying to do so hard to figure out what the answer may be.

P.S. I know nothing about C so not sure how much help I can be but other users do and with more info may be able to help.

GoRaiders007
12-03-2003, 10:26 AM
Thanks for your reply,
I don't have a dedicated server. Mysql and php were installed by Westhost. Both are installed as my php scripts work just fine. The php scripts also access mysql.

Yes the errors are from the linker, not the server, as it tries linking with the mysqlclient. I'm hoping someone else has tried compiling/linking a C app.

I couldn't follow the link from /usr/local/mysql/ although it is a symbolic link. I assumed that the c api libraries would be installed there, and I assumed that since I couldn't access the ./lib dir that the libraries for mysqlclient were residing elsewhere.

jalal
12-03-2003, 12:41 PM
You may want to try linking to the real location of the libraries at:

/lib/mysql/

Maybe the linker doesn't want to follow the links...

wildjokerdesign
12-03-2003, 01:06 PM
Are you on WestHost 1.0 or 2.0?

GoRaiders007
12-03-2003, 03:16 PM
Jalal,
I'll try your link suggestion. I'm guessing either the path is wrong or the libraries are just missing.

wildjokerdesign,
I'm still on WH 1.0, they gave up on 2.0 and have yet to convert my sites.

Odd thing is that I'm sure I ran into this problem before on my local box...I think the solution was to upgrade mysql??? If I can only recall. Thanks for you thoughts.

GoRaiders007
12-03-2003, 03:28 PM
FYI,
I found an explanation from mysql.com (http://www.mysql.com/doc/en/Link_errors.html), they recomend the following:
you should be able to solve this by adding -Lpath-to-the-mysql-library -lmysqlclient last on your link line.

But since I already added that, the path itself must be incorrect. I'll play with it some more.