Reputation: 181
The man page of dyld
(the dynamic link editor) says:
DYLD_FALLBACK_LIBRARY_PATH ... is a colon separated list of directories that contain libraries. It is used as the default location for libraries not found in their install path. By default, it is set to $(HOME)/lib:/usr/local/lib:/lib:/usr/lib.
However, contrary to the man page, DYLD_FALLBACK_LIBRARY_PATH is empty or undefined by default on Mac OS X, as shown by the following bash commands.
printenv DYLD_FALLBACK_LIBRARY_PATH
# OR
echo $DYLD_FALLBACK_LIBRARY_PATH
In fact, all the environment variables listed and explained on the man page of dyld
are empty or undefined, as revealed by the following bash script.
#!/bin/bash
while IFS=$'\n' read -r; do
printf %b "$REPLY = "
printenv "$REPLY"
echo
done < <(cat << EOF
DYLD_FRAMEWORK_PATH
DYLD_FALLBACK_FRAMEWORK_PATH
DYLD_LIBRARY_PATH
DYLD_FALLBACK_LIBRARY_PATH
DYLD_ROOT_PATH
DYLD_SHARED_REGION
DYLD_INSERT_LIBRARIES
DYLD_FORCE_FLAT_NAMESPACE
DYLD_IMAGE_SUFFIX
DYLD_PRINT_OPTS
DYLD_PRINT_ENV
DYLD_PRINT_LIBRARIES
DYLD_PRINT_LIBRARIES_POST_LAUNCH
DYLD_BIND_AT_LAUNCH
DYLD_NO_FIX_PREBINDING
DYLD_DISABLE_DOFS
DYLD_PRINT_APIS
DYLD_PRINT_BINDINGS
DYLD_PRINT_INITIALIZERS
DYLD_PRINT_REBASINGS
DYLD_PRINT_SEGMENTS
DYLD_PRINT_STATISTICS
DYLD_PRINT_DOFS
DYLD_NO_PIE
DYLD_SHARED_CACHE_DIR
DYLD_SHARED_CACHE_DONT_VALIDATE
EOF
)
Furthermore, while /etc/ld.so.conf
is where Linux stores all the directories that are searched by the loader in order to find the libraries, Mac OSX lacks /etc/ld.so.conf
.
Then, where does Mac OS X store the default search path for libraries?
Upvotes: 5
Views: 1855
Reputation: 181
jwdonahue added a comment saying that my question may be a duplicate to 7285587. Let me explain to him.
The difference between 7285587 and my question is that 7285587 asks what the default search path is.
I knew that the default search path is $(HOME)/lib:/usr/local/lib:/lib:/usr/lib
, as written on the man page of dyld, and I was aware of the existence of 7285587.
On the other hand, my question asks where the default search path is stored. Though the man page says that it is stored in the environment variable DYLD_FALLBACK_LIBRARY_PATH, I found that it is not stored in DYLD_FALLBACK_LIBRARY_PATH. Even though DYLD_FALLBACK_LIBRARY_PATH is empty, the configure
script and/or ld
seem(s) to learn the default search path from somewhere. Therefore, it seems that the default search path for libraries is stored somewhere other than DYLD_FALLBACK_LIBRARY_PATH.
I would like to know where it is stored, and how to verify it is $(HOME)/lib:/usr/local/lib:/lib:/usr/lib
.
By the way, I am trying to port programs for Linux to Mac OS X. My question has nothing to do with Cocoa or OSX-native programs. Hence, my question has nothing to do with /Library, /System/Library, or ~/Library.
Upvotes: 2
Reputation: 90681
Then, where does Mac OS X store the default search path for libraries?
It's simply hard-coded into the dynamic loader (dyld). Search for "sLibraryFallbackPaths" in this code. By the way, it shows that the man page is incorrect to include "/lib". That's not actually part of the default search path.
Upvotes: 3