Bug #21158 mysql_config doesn't include -lmygcc
Submitted: 19 Jul 2006 17:27 Modified: 25 Feb 2008 18:22
Reporter: Monty Taylor Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.0.41, 5.0.22 OS:Linux (linux)
Assigned to: Timothy Smith CPU Architecture:Any
Triage: D2 (Serious) / R3 (Medium) / E2 (Low)

[19 Jul 2006 17:27] Monty Taylor
I was trying to compile DBD::mysql at a client site, and got an error (I'm very sorry to say I don't remember the exact error... something about missing __pure_virtual. We discovered that the fix to this was to add -lmygcc to the libs. It seems that many people aroud the net are having problems compiling things against 5.0.22... and I'm guessing that the problem is that mysql_config doesn't list it in the list of required libraries, but it sure does seem to be required. 

How to repeat:
Install 5.0.22.
run cpan
install DBD::mysql
When it tries to do make test, it will fail spectacularly. 

Suggested fix:
Add -lmygcc to mysql_config --libs.
[19 Jul 2006 18:14] Sveta Smirnova
Thank you for the report.

Please, provide version of DBD::mysql you use.
[19 Jul 2006 18:44] Monty Taylor
Used DBD::mysql 3.0006. 

[19 Jul 2006 20:28] Sveta Smirnova
Verified as described on Linux using mysql-standard-5.0.22-linux-i686.tar.gz package.

With BK sources works fine.
[27 Jul 2006 7:59] Sveta Smirnova
We have similar bug #19532
[9 Aug 2006 0:44] Warner Moore
This affects PHP as well, which unfortunately does not use mysql_config directly.

Run configure:

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --with-apxs=/usr/local/apache/bin/apxs --with-zlib=/usr/local --with-gd=/usr/local --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --without-pear

Configure fails:

checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log for more information.

Config.log output:

see attachment.

My comments:

This is incredibly frustrating.  I had to hack out DBD::mysql to get it to work, now this...  I've yet to figure out a workaround I can implement in my build scripts.
[9 Aug 2006 0:46] Warner Moore
Bah, I cannot attach files.  Key output from config.log:

configure:62118: checking base type of last arg to accept
configure:62146: g++ -c   conftest.C 1>&5
configure:62195: checking return type of qsort
configure:62213: gcc -c -g -O2  conftest.c 1>&5
configure:62625: checking for mysql_close in -lmysqlclient
configure:62644: gcc -o conftest -g -O2  -Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib  -Wl,-rpath,/usr/local/lib -L/usr/local/lib conftest.c -lmysqlclient  -lgd -lpng -lz -ljpeg -lz -l
resolv -lm -ldl -lnsl  1>&5
/usr/local/mysql/lib/libmysqlclient.a(ssl.o)(.gnu.linkonce.d.__vt_Q25yaSSL7Message+0x8): undefined reference to `__pure_virtual'
/usr/local/mysql/lib/libmysqlclient.a(ssl.o)(.gnu.linkonce.d.__vt_Q25yaSSL7Message+0xc): undefined reference to `__pure_virtual'
/usr/local/mysql/lib/libmysqlclient.a(ssl.o)(.gnu.linkonce.d.__vt_Q25yaSSL7Message+0x10): undefined reference to `__pure_virtual'
/usr/local/mysql/lib/libmysqlclient.a(ssl.o)(.gnu.linkonce.d.__vt_Q25yaSSL7Message+0x14): undefined reference to `__pure_virtual'
/usr/local/mysql/lib/libmysqlclient.a(ssl.o)(.gnu.linkonce.d.__vt_Q25yaSSL7Message+0x18): undefined reference to `__pure_virtual'
/usr/local/mysql/lib/libmysqlclient.a(cert_wrapper.o)(.text+0x76): In function `yaSSL::x509::~x509(void)':
[9 Aug 2006 0:47] Warner Moore
Oh yes, this affects 5.0.24 as well.
[9 Aug 2006 0:59] Warner Moore
This affects the statically compiled binaries but not the dynamically compiled binaries.  I've not tested non x86 architecture nor have I tried the source packages.



Not affected:

[9 Aug 2006 18:33] Antony Dovgal
Looks like yet another issue caused by YaSSL addition.
See also http://bugs.mysql.com/bug.php?id=19817 and http://bugs.mysql.com/bug.php?id=19810
[13 Dec 2006 1:59] Jim Winstead
This is a server issue, not DBD::mysql.
[13 Dec 2006 17:42] Warner Moore
Substantiate your claim.
[31 Jul 2007 20:41] Larry Irwin
The Perl module DBD-mysql-4.005 does not compile properly because of some errors in the file "mysql_config".
I am using: mysqld  Ver 5.0.41-log for pc-linux-gnu on i686
The solution:
Edit /usr/local/mysql/bin/mysql_config.
Change any line containing "-mcpu" to "-march"
Change the line that contains:
libs=" $ldflags -L$pkglibdir -lmysqlclient -lz -lcrypt -lnsl -lm "
libs=" $ldflags -L$pkglibdir -lmysqlclient -lz -lcrypt -lnsl -lm -lmygcc "
Change the line that contains:
Change the line that contains:
Then this works as expected without any changes to the DBD-mysql distro.
perl Makefile.PL --testuser=[testuser] --testdb=test --testpassword=[testpassword]
make test
make install
[14 Feb 2008 8:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:


ChangeSet@1.2578, 2008-02-14 01:05:25-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #21158 mysql_config doesn't include -lmygcc
  Add -lmygcc to mysql_config output for libs, libs_r, and embedded_libs.
  Required when linking against our static libs, if yassl is used, and gcc
  used to build library is significantly different from that which is using
  the library.
[18 Feb 2008 21:33] Timothy Smith
Patch queued to 5.0-, 5.1-, and 6.0-build
[25 Feb 2008 15:59] Bugs System
Pushed into 5.1.24-rc
[25 Feb 2008 16:04] Bugs System
Pushed into 5.0.58
[25 Feb 2008 16:04] Bugs System
Pushed into 6.0.5-alpha
[25 Feb 2008 18:22] Paul Dubois
Noted in 5.0.58, 5.1.24, 6.0.5 changelogs.

mysql_config output did not include -lmygcc on some platforms when it
was needed.
[29 Mar 2008 23:49] Jon Stephens
Fix also documented for 5.1.23-ndb-6.3.11.