Wednesday, February 26, 2020

macOS: ld: warning: directory not found for option '-L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib'

If your PostgreSQL extension Makefile uses PGXS like in
PG_CONFIG = pg_config
...
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
And you updated MacOS since you installed PostgreSQL, you may experience the following error at compile time :
[jerome@jeroboam] > make
...
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -D_XOPEN_SOURCE  -L/usr/local/Cellar/postgresql@9.4/9.4.18/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib  -Wl,-dead_strip_dylibs   -bundle -bundle_loader /usr/local/Cellar/postgresql@9.4/9.4.18/bin/postgres -o src/pg_proctab.so src/pg_proctab.o
ld: warning: directory not found for option '-L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib'
Then replace MacOSX10.13 for CPPFLAGS and LDFLAGS in
[jerome@jeroboam] > sudo vi /usr/local/Cellar/postgresql\@9.4/9.4.18/lib/pgxs/src/Makefile.global
with e.g. MacOSX10.15.

MacOS: fatal error: 'sys/vfs.h' file not found

[jerome@jeroboam] > make
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -D_XOPEN_SOURCE  -I. -I./ -I/usr/local/Cellar/postgresql@9.4/9.4.18/include/server -I/usr/local/Cellar/postgresql@9.4/9.4.18/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o src/pg_proctab.o src/pg_proctab.c
src/pg_proctab.c:14:10: fatal error: 'sys/vfs.h' file not found
#include 
         ^~~~~~~~~~~
1 error generated.
make: *** [src/pg_proctab.o] Error 1
Then replace
#include <sys/vfs.h>
with
#if defined(__APPLE__)
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#endif