Missing PG_MODULE_MAGIC error - Mailing list pgsql-general

From Abhishek Chanda
Subject Missing PG_MODULE_MAGIC error
Date
Msg-id CAHmZhzFQ2=kH=_6ojHKLONi5UJoe5sTDEdHGJDRUyu7quEwLNw@mail.gmail.com
Whole thread Raw
List pgsql-general
Hi all,

I am trying to test an extension that links to rocksdb. When I try to load it in postgres, it complains "missing magic block" while I do have PG_MODULE_MAGIC in my src. Here is a minimal repro

// pgtam.c
#include "postgres.h"
#include <assert.h>
#include "fmgr.h"
#include "access/tableam.h"
#include "access/heapam.h"
#include "nodes/execnodes.h"
#include "catalog/index.h"
#include "commands/vacuum.h"
#include "utils/builtins.h"
#include "executor/tuptable.h"

#include "rocksdb/c.h"

PG_MODULE_MAGIC;

// Makefile
MODULE_big = pgtam
EXTENSION = pgtam
DATA = pgtam--0.0.1.sql

PG_CPPFLAGS += -L/usr/local/lib -g
SHLIB_LINK += -L/usr/local/lib -lrocksdb

PG_CONFIG = /usr/local/pgsql/bin/pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

// extension build
╰─$ make clean && make && sudo make install
rm -f pgtam.dylib   libpgtam.a  libpgtam.pc
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -g -ggdb -Og -g3 -fno-omit-frame-pointer  -fvisibility=hidden -bundle -o pgtam.dylib  -L/usr/local/pgsql/lib  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk   -Wl,-dead_strip_dylibs   -fvisibility=hidden -L/usr/local/lib -lrocksdb -bundle_loader /usr/local/pgsql/bin/postgres
/opt/homebrew/bin/gmkdir -p '/usr/local/pgsql/lib'
/opt/homebrew/bin/gmkdir -p '/usr/local/pgsql/share/extension'
/opt/homebrew/bin/gmkdir -p '/usr/local/pgsql/share/extension'
/opt/homebrew/bin/ginstall -c -m 755  pgtam.dylib '/usr/local/pgsql/lib/pgtam.dylib'
/opt/homebrew/bin/ginstall -c -m 644 .//pgtam.control '/usr/local/pgsql/share/extension/'
/opt/homebrew/bin/ginstall -c -m 644 .//pgtam--0.0.1.sql  '/usr/local/pgsql/share/extension/'

Postgres build: cloned and built at SHA 849172ff4883d44168f96f39d3fde96d0aa34c99

╰─$ /usr/local/pgsql/bin/pg_ctl -D test-db -l logfile restart
waiting for server to shut down.... done
server stopped
waiting for server to start.... done
server started                                                                                                                                  
╭─~/src/postgres ‹849172ff48●›
╰─$ /usr/local/pgsql/bin/psql postgres
psql (17devel)
Type "help" for help.

postgres=# CREATE EXTENSION pgtam;
ERROR:  incompatible library "/usr/local/pgsql/lib/pgtam.dylib": missing magic block
HINT:  Extension libraries are required to use the PG_MODULE_MAGIC macro.

What am I missing?

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: CLUSTER vs. VACUUM FULL
Next
From: Saksham Joshi
Date:
Subject: Re: Not able to grant access on pg_signal_backend on azure flexible server