Bug #61699 OSX mysql builds link libmysqlclient to itself
Submitted: 29 Jun 2011 18:50 Modified: 5 Feb 2014 1:32
Reporter: Quanah Gibson-Mount Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.5.13, 5.5.20, 5.5.22 OS:MacOS
Assigned to: CPU Architecture:Any

[29 Jun 2011 18:50] Quanah Gibson-Mount
Description:
When you build mysql on OSX 10.6 using cmake, the resulting libmysqlclient dylib file links to itself, which is very bizarre:

sh-3.2# otool -L libmysqlclient.18.dylib
libmysqlclient.18.dylib:
        /Users/build/p4/main/ThirdParty/mysql/mysql-5.5.13/libmysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
        /opt/zimbra/openssl-1.0.0d/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /opt/zimbra/openssl-1.0.0d/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)

This behavior is not exhibited on Linux builds.

In addition, when installing libmysqlclient via the CMake method, the RUNPATH is not set, making the library unusable for linking to other applications:

sh-3.2# otool -L /opt/zimbra/mysql-standard-5.5.13-apple-darwin10-i386/lib/libmysqlclient.18.dylib
/opt/zimbra/mysql-standard-5.5.13-apple-darwin10-i386/lib/libmysqlclient.18.dylib:
        libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
        /opt/zimbra/openssl-1.0.0d/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /opt/zimbra/openssl-1.0.0d/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)

How to repeat:
Build Mysql on OSX using CMAKE

Suggested fix:
Fix whatever broken linking methodology MySQL came up with for OSX.
[29 Jun 2011 20:58] Quanah Gibson-Mount
The install RPATH issue on Apple can be fixed with the following patch:

--- mysql-5.5.13/libmysql/CMakeLists.txt.orig   2011-06-29 13:24:53.000000000 -0700
+++ mysql-5.5.13/libmysql/CMakeLists.txt        2011-06-29 13:25:48.000000000 -0700
@@ -24,6 +24,10 @@
   ${ZLIB_INCLUDE_DIR})
 ADD_DEFINITIONS(${SSL_DEFINES})

+IF (APPLE)
+   SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+ENDIF()
+
 SET(CLIENT_API_FUNCTIONS
 load_defaults
 mysql_thread_end
[25 Mar 2012 12:37] Valeriy Kravchuk
I still see this in recent 5.5.22:

macbook-pro:mysql-5.1 openxs$ otool -L /usr/local/mysql-5.5.22-osx10.5-x86_64/lib/libmysqlclient.18.dylib 
/usr/local/mysql-5.5.22-osx10.5-x86_64/lib/libmysqlclient.18.dylib:
	libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
[18 Apr 2012 11:37] Matt Connolly
Bug still present in 5.5.22. Please include this patch to fix the install_name of libmysqlclient.18.dylib
[20 Nov 2012 20:44] Zach Dennis
Bug is still present on 5.5.27 as well.
[21 Oct 2013 10:45] Sierk Bornemann
Still an issue on MySQL 5.6.x and MySQL 5.7.x.

When will it be finally fixed?
[5 Feb 2014 1:32] Paul DuBois
Noted in 5.7.4 changelog.

On Mac OS X, the libmysqlclient dylib file linked to itself.