4

I need to understand which version of sqlite3 is used by a GUI app.

I have several versions installed on my machine and I want to know which one is available to MacOS GUI app. There must be a place which defines a PATH to the GUI apps.

How can I know ? How can I modify it?

  • Some apps & frameworks provide and use their own sqlite binary (e.g. Onyx or Mono)! – klanomath Apr 8 '18 at 13:09
  • You need to know how the app was built - good apps will have the sqlite library in their bundle or staically linked ot it will use the one defined in their build or if originally written for another Unix the LD_LIBRARY_PATH might be used - although later versions of OSX make that harder to do developer.apple.com/library/content/documentation/… In short ask the developer – user151019 Apr 8 '18 at 17:35
7

Assuming SQLite is dynamically linked into the running application, you can find the PATH environment variable using the ps command.

Alternatively, use Activity Monitor to view the application's Open Files and Ports. You can then search the output to see if the library is being held open by the process.

Path - Use ps

PATH is part of a process's environment variables. If you can see those, you will find PATH.

Use the ps tool with the flags -wwwE on macOS to view the environment variables passed to a process:

ps -p <PID> -wwwE

See Environment variables of a running process on Unix?

Example

Below is an example output from running this command on the graphical Mac application Xcode:

ps -p 1648 -wwwE

  PID TTY           TIME CMD
 1648 ??         0:03.46 /Applications/Xcode.app/Contents/MacOS/Xcode TMPDIR=/var/folders/b2/[redacted]n/T/ __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2 HOME=[redacted] SHELL=/bin/bash Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.[redacted]/Render SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.[redacted]/Listeners PATH=/usr/bin:/bin:/usr/sbin:/sbin LOGNAME=[redacted] DISPLAY=/private/tmp/com.apple.launchd.[redacted]/org.macosforge.xquartz:0 XPC_SERVICE_NAME=com.apple.dt.Xcode.64852 MallocNanoZone=0 USER=[redacted] XPC_FLAGS=0x1

As Mark mentions in a comment below, this may not show the linked library.

Linked Library Info - Use otool

As another alternative, try otool to extract the linked framework and library information. The command to run is:

otool -L <path to binary>

Using Xcode.app as an example, the command and output is:

$ otool -L /Applications/Xcode.app/Contents/MacOS/Xcode 
/Applications/Xcode.app/Contents/MacOS/Xcode:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
    @rpath/DVTFoundation.framework/Versions/A/DVTFoundation (compatibility version 1.0.0, current version 1.0.0)
    @rpath/DVTKit.framework/Versions/A/DVTKit (compatibility version 1.0.0, current version 1.0.0)
    @rpath/IDEFoundation.framework/Versions/A/IDEFoundation (compatibility version 1.0.0, current version 14154.0.0)
    @rpath/IDEKit.framework/Versions/A/IDEKit (compatibility version 1.0.0, current version 14154.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1452.20.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1561.40.104)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1452.20.0)
    @rpath/libswiftAVFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreAudio.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftCoreMedia.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftMetal.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftXPC.dylib (compatibility version 1.0.0, current version 902.0.48)
    @rpath/libswiftsimd.dylib (compatibility version 1.0.0, current version 902.0.48)

Relinking

Relinking a binary is not advisable but seemingly possible. See How to copy (and relink) binaries on OSX using otool and install_name_tool for detailed instructions.

|improve this answer|||||
  • 1
    However PATH is not used for dybamic load libraries – user151019 Apr 8 '18 at 17:27
  • Thank you. With ps @coolnodje can find the path information asked for in the question, and I have expanded the answer to introduce otool to show the linked libraries. Hopefully this will help them find the information they want. – Graham Miln Apr 8 '18 at 19:34
  • I hope so but the adding to PATH to get shared libraries is the Windows way so I suspect it is more complex - and your answer does not gibe a way to chnage the libs :( – user151019 Apr 9 '18 at 13:54
  • otool -L $BINARY ## list shared libraries; otool -l $BINARY | grep 'path ' ## list @rpath; – Devon Sean McCullough Mar 9 '19 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .