Bug #2288 libmysqlclient requires -lm in gcc command

Submitted: 5 Jan 2004 9:06 Modified: 5 Jan 2004 9:38
Reporter: Barry Byrne Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.17 OS:sparc Solaris 8
Assigned to: Dean Ellis CPU Architecture:Any

[5 Jan 2004 9:06] Barry Byrne
Description:
I installed the binary of 4.0.17 and ran the compilation

gcc -o report_listener *.c -lsocket  -lnsl -lmysqlclient \ -I/usr/local/mysql/include -L/usr/local/mysql/lib

and got the report
Undefined                       first referenced
 symbol                             in file
floor                       /usr/local/mysql/lib/libmysqlclient.a(password.o)
ld: fatal: Symbol referencing errors. No output written to report_listener
collect2: ld returned 1 exit status

I changed the compilation line to 
gcc -o report_listener *.c -lsocket  -lnsl -lmysqlclient -lm\ -I/usr/local/mysql/include -L/usr/local/mysql/lib
and it worked.

How to repeat:
It looks as though you have to have some code that invokes password.c
in libmysqlclient
maybe just
 if(mysql_real_connect(&mysql, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0) == NULL) {

Suggested fix:
Use -lm in the compilation command.
[5 Jan 2004 9:16] Dean Ellis
Check mysql_config --libs to see that -lm is specified.  If so, this is not a bug.
[5 Jan 2004 9:23] Barry Byrne
I have now checked mysql_config
bash-2.05$ mysql_config --libs
-L/usr/local/mysql/lib -lmysqlclient -lposix4 -lcrypt -lgen -lsocket -lnsl -lm

(as you predicted)

Thanks for your quick response; what part of the documentation have I missed?
[5 Jan 2004 9:26] Barry Byrne
Rhetorical question!
4.9.11
[5 Jan 2004 9:38] Dean Ellis
Also 12.1.13 "Building Client Programs", which references this as well.

It is easy to overlook.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.076 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.