Libssl and libcrypto causing dyld: Library not loaded: /usr/lib/libpq.5.dylib

16,403

Solution 1

Turns out /usr/lib/libpq.5.dylib was absent but /usr/lib/libpq.5.4.dylib was not.

sudo ln -s /usr/lib/libpq.5.4.dylib /usr/lib/libpq.5.dylib

fixed the issue.

Solution 2

Not unlike @Pablo Marambio, I fixed this issue by adding the following line to ~/.profile:

export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib:$DYLD_LIBRARY_PATH

For Postgres.app v9.3.5.0 (presumably others too) I added the following line instead:

export DYLD_LIBRARY_PATH=/Applications/Postgres.app/Contents/Versions/9.3/lib:$DYLD_LIBRARY_PATH

Then, of course, run source ~/.profile

Solution 3

To resolve this, I had to uninstall postgresql and then install again.

$ brew uninstall postgresql

$ brew update

$ brew install postgres
Share:
16,403
xjq233p_1
Author by

xjq233p_1

(your about me is currently blank)

Updated on July 24, 2022

Comments

  • xjq233p_1
    xjq233p_1 almost 2 years

    I recently uninstalled postgresql and installed pyscopg2 via pip.

    I know there's some trickery involved with libcrypto and libssl

    Currently i have them symlinked to:

    $ ls -lah libssl.*
    -rwxr-xr-x  1 root  wheel   402K Aug 28 11:06 libssl.0.9.7.dylib
    -rwxr-xr-x  1 root  wheel   589K Aug 28 11:06 libssl.0.9.8.dylib
    lrwxr-xr-x  1 root  wheel    55B Nov 29 23:38 libssl.1.0.0.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
    lrwxr-xr-x  1 root  wheel    55B Nov 30 02:25 libssl.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
    
    /usr/lib
    $ ls -lah libcrypto.*
    -rwxr-xr-x  1 root  wheel   2.1M Aug 28 11:06 libcrypto.0.9.7.dylib
    -rwxr-xr-x  1 root  wheel   2.6M Aug 28 11:06 libcrypto.0.9.8.dylib
    -r-xr-xr-x  1 root  wheel   1.6M Oct 31 22:12 libcrypto.1.0.0.dylib
    lrwxr-xr-x  1 root  wheel    58B Nov 30 02:27 libcrypto.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libcrypto.1.0.0.dylib
    

    whereby I installed openssl via ports

    Now when I run arc diff, I am getting the infamous

    $ arc diff
    dyld: Library not loaded: /usr/lib/libpq.5.dylib
      Referenced from: /usr/bin/php
      Reason: image not found
    Trace/BPT trap: 5
    

    There are a few answers here in SO which talks about symlinking these libs to the postgresql install directory. Obviously, this won't work for me.

    What should I do?

    • Admin
      Admin over 11 years
      What's arc? Also, I see /usr/bin/php; that doesn't look very Python to me. And if you uninstalled postgresql, I'm not so sure that pip will install postgresql for you if you install psycopg2 (though, if it doesn't, it should probably fail). Do you have a libpq (any) on your system?
    • Admin
      Admin about 10 years
  • Pablo Marambio
    Pablo Marambio over 10 years
    In my case, the library was in /Library/PostgreSQL/9.3/lib. To solve the issue, I ran export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib:$DYLD_LIBRARY_‌​PATH
  • Usama Ahmed
    Usama Ahmed about 10 years
    @PabloMarambio your solution also worked for me. Thanks
  • Sam Texas
    Sam Texas over 9 years
    I like this exporting environment variable better than copying or symlinking libraries on my system.
  • Ammar Akhtar
    Ammar Akhtar over 9 years
    other way around for for me..! sudo ln -s /usr/lib/libpq.5.dylib /usr/lib/libpq.5.6.dylib
  • Raymond26
    Raymond26 almost 8 years
    This breaks running "psql DBNAME" in the command line for me. Running Postgres.app v9.5.0.0 and the error returned says "dyld: Symbol not found: __cg_jpeg_resync_to_restart"
  • pierroz
    pierroz over 3 years
    This solution was almost mine too but in addition, since I'm using a specific version of postgresql, I also needed a brew link: $ brew uninstall postgresql@11 && brew update && brew install postgresql@11 && brew link --force postgresql@11
  • A K
    A K over 2 years
    For macos big sur i do symlink for /usr/local/lib/libpq.5.dylib
  • thedevd
    thedevd about 2 years
    It is not working for me
  • Marlon Abeykoon
    Marlon Abeykoon about 2 years
    brew link --force postgresql@11 did the magic here