osx 10.11 El Capitan and MySQL

Hi,


First off all, sorry for my English.


I've updraded Yosemite to El Capitan and installed XCode 7.0. My app uses MySQL and it ran ok on Yosemite. Now, when I start it, XCode gives me this error:



dyld: Library not loaded: libmysqlclient.18.dylib

Referenced from: /Users/jose/Library/Developer/Xcode/DerivedData/SaDPeMAC-dvophlqioihoungqcdkihvpzskee/Build/Products/Debug/SaDPeMAC.app/Contents/MacOS/SaDPeMAC

Reason: image not found


Don't know what to do. Could anyone help me?

Replies

Backup any data you have and reinstall mySQL.

I have just done it. I erased a disk, and I reinstall everything from scratch. I still have the same error. Any ideas?

Depending on how MySQL was installed, the library might not be loading because it couldn't be found. Type the following into Terminal to create a symbolic link (It's all one line, not two):


ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

When typing that, I get "Operation not permitted".


I guess it has to do with improved OS security in OSX 10.10 (rootless).


When using YOSEMITE it worked doing...


1. sudo ln /usr/local/mysql-5.6.25-osx10.8-x86_64/bin/mysql /usr/bin/mysql)

2. export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

3. sudo ln /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib


but commands 1 y 3 are not permitted in OSX 10.10 and command 2 doesn't seem to work


I feel that the solution is quite simple, but I am lost.

You're right, it's because SIP/rootless prevents access to usr/lib/


You can temporarily disable SIP by holding cmd+r at bootup to get to Recovery HD. Then Utilities > Security Configuration menu. Uncheck "Enforce System Integrity Protection" and click "Apply Configuration".


Once SIP is disabled, you should just reinstall MySQL.


When you've got it working you can re-enable SIP.

Thank you Max!!!


I found this solution yesterday googling around but I learnt that it would not be available in the final release 😟 . Do you have any othe ideas?


Thank you again.

What's the result of running:

locate libmysqlclient.18.dylib

Where did you read that the ability to temporarily disable SIP will be absent from the final release?

This is the result:


MacBook-Pro-de-Jose:~ jose$ locate libmysqlclient.18.dylib

/usr/local/mysql-5.6.25-osx10.8-x86_64/lib/libmysqlclient.18.dylib



Once again thank you Max. You don't know how I appreciate your help.

Give me a minute and I'll try to find it again

Can't find it now, but I saw it yesterday. It was written as a reply from someone in Apple. I'll keep looking for it.

The following is from StackOverflow:


At build time the static linker on OS X, ld, writes the shared library identifier of each library that your application links against in to the application binary. At run time the dynamic linker, dyld, attempts to load each shared library from the paths specified in the application binary. You can see this information using

otool -L YourApp.app/Contents/MacOS/YourApp
.


The fact you needed to symlink libmysqlclient.18.dylib in to /usr/lib suggests that the shared library identifier of libmysqlclient.18.dylib is something like /usr/lib/libmysqlclient.18.dylib. To include the library in your .app bundle in a way that your application will use it rather than looking in /usr/lib you need to:


  1. Change the shared library identifier of libmysqlclient.18.dylib so that dyld will look for the binary relative to your application binary. This is typically done by running
    install_name_tool -id @executable_path/../Frameworks/libmysqlclient.18.dylib libmysqlclient.18.dylib
    .
  2. Copy the modified libmysqlclient.18.dylib in to the Frameworks subdirectroy in your application bundle. This is typically done using a Copy Files build phase in your Xcode project.

You should then be able to verify that the install name written in to your application binary is

@executable_path/../Frameworks/libmysqlclient.18.dylib
rather than
/usr/lib/libmysqlclient.18.dylib 
(using
otool -L YourApp.app/Contents/MacOS/YourApp
again). If the install name isn't correct then you'll need to ensure that your linker search path is set up to find your modified version of libmysqlclient.18.dylib ahead of any other versions you may have.

Found it


If you google "notes from thursday security lab" you'll get to an apple developer forum that says...


Question:


There is a nvram boot-args command available in Developer Beta 1 which can disable SIP when run with root privileges:


nvram boot-args="rootless=0"


Will this option of disabling SIP also be available in the El Capitan release version? Or is this strictly for the Developer Builds?


Answer:


This nvram boot-args command will be going away. It will not be available in the El Capitan release version and may disappear before the end of the Developer Betas. Keep an eye on the release notes for future Developer Betas.

Thank you for finding that for me. I can understand the terminal command going away because it disables SIP with more collateral effect than doing so through booting into Recovery to disable it. My guess is that the new Security Configuration menu in Recovery will continue to be supported because it was created for this very purpose.

Mmmmmmm.... I am doing something wrong. Look.... I've checked the spelling and it is ok.



MacBook-Pro-de-Jose:~ jose$ otool -L SaDPeMAC.APP/Contents/MacOS/SaDPeMAC

error: /Library/Developer/CommandLineTools/usr/bin/otool: can't open file: SaDPeMAC.APP/Contents/MacOS/SaDPeMAC (No such file or directory)


I can see the file there!!!