BUG #16737: error running compiled C program with connection to Postgres
The following bug has been logged on the website:
Bug reference: 16737
Logged by: richard bee
Email address: rb9999999@gmail.com
PostgreSQL version: 13.1
Operating system: Mac iOS Big Sur
Description:
This is an issue for both Apple and Postgres - I have registered the same
issue with Apple here:
https://feedbackassistant.apple.com/feedback/8907834
when running a compiled C program with connection attributes to postgres, I
now get the following error after upgrading to Big Sur:
dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /xxdir/program
Reason: image not found
Abort trap: 6
indeed, there is nothing in /usr/lib directory that resembles
libpq.5.dylib,
neither file nor link
and the /usr/lib directory in Big Sur is locked down and so cannot enter
anything here
have implemented the following without resolution:
https://stackoverflow.com/questions/64256675/copy-libpq-5-dylib-to-usr-lib-libpq-5-dylib
The code itself is the usual example of C to Progress connection code and
worked prior to Big Sur upgrade on my macbook pro 2018
sample c program to compile is here:
https://www.postgresql.org/docs/9.1/libpq-example.html
compilation command being used is:
gcc -o e1_ e1.c -I "/Library/PostgreSQL/13/include" -lpq -std=c99
The same error also happens with the clang compiler
PG Bug reporting form <noreply@postgresql.org> writes:
when running a compiled C program with connection attributes to postgres, I
now get the following error after upgrading to Big Sur:
dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /xxdir/program
Reason: image not found
Abort trap: 6
Complaining here won't help you with that. The Postgres project has
no say in what Apple chooses to include in their operating system.
Having said that, the version that Apple was shipping up through
Catalina was pretty darn obsolete:
$ ls -1 /usr/lib/libpq*
/usr/lib/libpq.5.6.dylib
/usr/lib/libpq.5.dylib
/usr/lib/libpq.dylib
libpq.5.6 would be from Postgres 9.3, which has been out of support
for some time ... and it'd be a very good bet that this wasn't an
end-of-life version anyway, meaning it's certainly missing security
and other bug fixes. So personally I wouldn't use that anyway.
The most obvious path forward is to use Homebrew or MacPorts to
install Postgres, as well as anything else you need. (It looks
like Apple culled a heck of a lot from /usr/lib in Big Sur,
not only libpq.)
regards, tom lane