Dynamic linker environment variables setup on Darwin
Summary
Folder existence check was introduced on Darwin in _foamAddLib
function. The function fails, when multiple folders separated by colon are passed as an argument. Due to this bug FOAM_USER_LIBBIN
and FOAM_SITE_LIBBIN
are not added to DYLD_LIBRARY_PATH
.
Steps to reproduce
- Setup OpenFOAM(R) environment.
- Look at
DYLD_LIBRARY_PATH
: neitherFOAM_USER_LIBBIN
, norFOAM_SITE_LIBBIN
are there.
What is the current bug behaviour?
FOAM_USER_LIBBIN
and FOAM_SITE_LIBBIN
are missing from DYLD_LIBRARY_PATH
, so user-compiled libraries are not found by dynamic linker.
What is the expected correct behavior?
Libraries located in FOAM_USER_LIBBIN
or FOAM_SITE_LIBBIN
should be found by dynamic linker.
Environment information
- OpenFOAM version : v2312
- Operating system : macOS
- Compiler : clang
Possible fixes
There are two possible approaches to fix the issue.
-
Remove
-e
check from_foamAddLib
function. I.e. change this (etc/config.sh/functions:92
)_foamAddLib() { case "$1" in (/?*) if [ -e "$1" ] then export FOAM_LD_LIBRARY_PATH="${1}${FOAM_LD_LIBRARY_PATH:+:}${FOAM_LD_LIBRARY_PATH}" export DYLD_LIBRARY_PATH="$FOAM_LD_LIBRARY_PATH" fi esac }
to
_foamAddLib() { case "$1" in (/?*) export FOAM_LD_LIBRARY_PATH="${1}${FOAM_LD_LIBRARY_PATH:+:}${FOAM_LD_LIBRARY_PATH}" export DYLD_LIBRARY_PATH="$FOAM_LD_LIBRARY_PATH" esac }
The same should be applied to
csh
functions. -
Do not pass multiple folders to
_foamAddLib
function, effectively splitting single function call to multiple. I.e. instead of this (etc/config.sh/setup:233
):_foamAddLib "$FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN"
use this
_foamAddLib "$FOAM_SITE_LIBBIN" _foamAddLib "$FOAM_USER_LIBBIN" # User library folder has higher priority
grep -r
inetc
folder shows, that this line is a single invocation of_foamAddLib
with multi-folder argument. So, maybe, this approach is easier.