How to Fix ‘Dyld: Library not Loaded’ Error on MacOS
MacOS developed and distributed by Apple is surely one of the most reliable Operating System out there. It is used mostly by professionals who intend to use their computers for business purposes. However, quite recently a lot of reports have been coming in of a “Dyld: Library Not Loaded” Error on MacOS. In this article, we will discuss the reason due to which this error is triggered and also provide viable solutions in order to fix them.
What Causes the “Dyld: Library Not Loaded” Error on MacOS?
After receiving numerous reports, we decided to investigate the issue and identified the reason due to which this error is triggered.
- Invalid Location: This error is triggered when the computer tries to find the “libmysqlclient.18.dylib” file or a file similar to that under the “usr/lib” location. The file is quite obviously not present in this location due to which the error is triggered.
Now that you have a basic understanding of the nature of the problem we will move on towards the solutions. Make sure to implement these in the specific order in which they are provided to avoid any conflicts.
Solution 1: Creating a Symbolic Link
It is possible to counter the problem by creating a Symbolic Link in the directory where the computer is checking for the “.dylib” file. In order to do that:
- Navigate to the “/usr/lib” folder.
- Press the “Command” + “Space” simultaneously.
- Type in “Terminal” and press “Enter“.
- Type the following command in the terminal and press “Enter”
sudo ln -s /path/to/your/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
An example of the above command looks like this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
- Check to see if the issue persists.
Solution 2: Updating Brew
In some cases, this file is missing from the directory due to an outdated installation of “Brew”. Therefore, in this step, we will be updating Brew. In order to do that:
- Press the “Command” + “Space” simultaneously.
- Type in “Terminal” and press “Enter“.
- Type in the following command in the terminal and press “Enter“.
brew update
- Again, type in the following command in the terminal and press “Enter”.
brew upgrade
- Check to see if the issue persists.
Solution 3: Running a “Copy_dylibs.py” Script
In some cases, the references for the “.dylib” files aren’t correct due to which this error is triggered. Therefore, in this step, we will be running a script which will automatically detect and fix these issues. In order to do that:
- Click on this link and download the script.
- Extract the contents of the “.zip” file.
- Read the “readme” included in the “.zip” file carefully for detailed instructions.
- Run the “copy_dylibs.py” script and let it fix the issue
- Check to see if the issue persists.