Under OpenBSD I use a so-called install.site customization script, which is run by the installer at the end of the OBSD install.
When I add binary packages with the OBSD pkg_add, I first initialize the share library cache with the following
Code:
echo Configure shared library cache with code stolen from "/etc/rc"
echo Assuming you did not override the empty 'shlib_dirs' from '/etc/rc.conf' in '/etc/rc.co
nf.local'
if [ -f /sbin/ldconfig ]; then
echo 'creating runtime link editor directory cache.'
if [ -d /usr/local/lib ]; then
shlib_dirs="/usr/local/lib $shlib_dirs"
fi
if [ -d /usr/X11R6/lib ]; then
shlib_dirs="/usr/X11R6/lib $shlib_dirs"
fi
ldconfig $shlib_dirs
fi
BTW You also could print out the the environment with
env(1) and see what are the differences.