Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is most likely no translated for the post!





Share:
Notifications
Clear all

macOS - Where to put your dylib files during development without installing them?  

  RSS

Hans
 Hans
(@hans)
Noble Member Admin
Joined: 7 years ago
Posts: 1373
May 26, 2020 6:13 AM  

From the Apple documentation:

Before you can use a dynamic library as a dependent library, the library and its header files must be installed on your computer.

The standard locations for header files are (not always needed):

~/include
/usr/local/include
/usr/include

The standard locations for dynamic libraries (dylib files) are:

~/lib
/usr/local/lib
/usr/lib.

You may also place the .dylib file at a nonstandard location in your file system, but you must add that location to one of these environment variables:

LD_LIBRARY_PATH
DYLD_LIBRARY_PATH
DYLD_FALLBACK_LIBRARY_PATH

 

So in short, this is what I do when developing an application that needs a dylib:

1) For the development process, I copy the dylib file to ~/lib - This way my IDE (Lazarus Pascal) can find the dylib.

2) When testing for deployment, I remove the dylib from ~/lib, so I can test if I added the dylib correctly in the .app bundle.

Typically I create 2 scripts for that (MySQL client dylib example): 

install-dylib.sh

mkdir ~/lib
cp libmysqlclient.20.dylib ~/lib
cd ~/lib
ln -s libmysqlclient.20.dylib libmysqlclient.dylib

and

uninstall-dylib.sh

rm ~/lib/libmysqlclient.dylib
rm ~/lib/libmysqlclient.20.dylib

Don't forget to do

chmod +x install-dylib.sh
chmod +x uninstall-dylib.sh

Also note that in the install script, I do a symbolic link to a generic name (no version number).


ReplyQuote
Share: