0

Platform MacOs Sequoia 15.5.

My objective is to enable an application to find a dynamic library.

My plan is to use launchctl to set the environment variable DYLD_LIBRARY_PATH and then lanch the application.

It appears that launchctl will not do this, there seems to be something special about this specific environment variable.

launchctl setenv DYLD_LIBRARY_PATH /Library/ODBC/ODBCDataSources
launchctl getenv DYLD_LIBRARY_PATH
    ... result nothing, not output

Try a different environment variable:

launchctl setenv SDYLD_LIBRARY_PATH /Library/ODBC/ODBCDataSources
launchctl getenv SDYLD_LIBRARY_PATH                              
/Library/ODBC/ODBCDataSources.  <== result as expected

The reason I'm doing this is I want Excel to connect to my postgres database. I have ODBC drivers installed and the driver requires a dynamic library. The sandbox system prevents the loading. I needed to place the psqlodbca.so in a /Library/ODBC/ODBCDataSources, but I can't find how to control the search path for libpq.5.dylib

Full error message:

dlopen(/Library/ODBC/ODBCDataSources/psqlodbca.so, 0x0006): Library not loaded: /opt/homebrew/opt/libpq/lib/libpq.5.dylib Referenced from: <123026D6-8774-396E-AB04-63B223BD966F> /Library/ODBC/ODBCDataSources/psqlodbca.so Reason: tried: '/opt/homebrew/opt/libpq/lib/libpq.5.dylib' (file system sandbox blocked open()), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libpq/lib/libpq.5.dylib' (no such file), '/opt/homebrew/opt/libpq/lib/libpq.5.dylib' (file system sandbox blocked open())

I'd welcome any suggestions

4
  • How do you run your application? Commented Aug 2 at 6:24
  • @Philippe I launch Excel from the dock. Commented Aug 3 at 6:27
  • Can you try DYLD_LIBRARY_PATH=/Library/ODBC/ODBCDataSources path-to-excel to see if it works? Commented Aug 3 at 22:39
  • The lib must be within your app sandbox. /opt/homebrew is not part of any app sandbox. Commented Sep 25 at 8:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.