How to see library search paths MacOS? There are two Macs and one of them finds a certain dylib when I dlopen it and another one doesn't. Seems like the library search paths are different, but DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH are empty on both machines.

How can I see what paths dlopen searches?
You'll find the list of paths (i.e. list of variables containing the paths) in the man page for dyld. You can view the man page by running the following command in the Terminal:

man dyld


For example you might have a difference in LC_RPATH or similar. I suggest printing out the environment on both machines and comparing notes.

If you come from a Linux background and expect a file like /etc/ld.so.conf on Linux, then no such file exists on macOS.

Another reason for difference between the code could be one not having an update dyld cache. You can run the following command to update the cache:

update_dyld_shared_cache


Remember to reboot afterwards to actually use the cache.

In general it sounds like the program you have that does dlopen is programmed a bit odd. Typically programs do not dlopen() various dylib at paths not relative to the executable, the loader or the program's built-in rpath in rare cases.