[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Missing PG_MODULE_MAGIC error
From:       Abhishek Chanda <rony358 () gmail ! com>
Date:       2024-04-22 3:18:53
Message-ID: CAHmZhzFQ2=kH=_6ojHKLONi5UJoe5sTDEdHGJDRUyu7quEwLNw () mail ! gmail ! com
[Download RAW message or body]

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?

[Attachment #3 (text/html)]

<div dir="ltr">Hi all,<div><br></div><div>I am trying to test an extension  that \
links to rocksdb. When I try to load it in postgres, it complains  &quot;missing \
magic block&quot; while I do have  PG_MODULE_MAGIC in my src. Here is a minimal \
repro</div><div><br></div><div>// pgtam.c</div><div>#include \
&quot;postgres.h&quot;<br>#include &lt;assert.h&gt;<br>#include \
&quot;fmgr.h&quot;<br>#include &quot;access/tableam.h&quot;<br>#include \
&quot;access/heapam.h&quot;<br>#include &quot;nodes/execnodes.h&quot;<br>#include \
&quot;catalog/index.h&quot;<br>#include &quot;commands/vacuum.h&quot;<br>#include \
&quot;utils/builtins.h&quot;<br>#include \
&quot;executor/tuptable.h&quot;<br><br>#include \
&quot;rocksdb/c.h&quot;<br><br>PG_MODULE_MAGIC;<br></div><div><br></div><div>// \
Makefile</div><div>MODULE_big = pgtam<br>EXTENSION = pgtam<br>DATA = \
pgtam--0.0.1.sql<br><br>PG_CPPFLAGS += -L/usr/local/lib -g<br>SHLIB_LINK += \
-L/usr/local/lib -lrocksdb<br><br>PG_CONFIG = /usr/local/pgsql/bin/pg_config<br>PGXS \
:= $(shell $(PG_CONFIG) --pgxs)<br>include $(PGXS)<br></div><div><br></div><div>// \
extension build</div><div>╰─$ make clean &amp;&amp; make &amp;&amp; sudo make \
install<br>rm -f pgtam.dylib    libpgtam.a   libpgtam.pc<br>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<br>/opt/homebrew/bin/gmkdir -p \
&#39;/usr/local/pgsql/lib&#39;<br>/opt/homebrew/bin/gmkdir -p \
&#39;/usr/local/pgsql/share/extension&#39;<br>/opt/homebrew/bin/gmkdir -p \
&#39;/usr/local/pgsql/share/extension&#39;<br>/opt/homebrew/bin/ginstall -c -m 755   \
pgtam.dylib &#39;/usr/local/pgsql/lib/pgtam.dylib&#39;<br>/opt/homebrew/bin/ginstall \
-c -m 644 .//pgtam.control \
&#39;/usr/local/pgsql/share/extension/&#39;<br>/opt/homebrew/bin/ginstall -c -m 644 \
.//pgtam--0.0.1.sql   \
&#39;/usr/local/pgsql/share/extension/&#39;<br></div><div><br></div><div>Postgres \
build: cloned and built at SHA \
849172ff4883d44168f96f39d3fde96d0aa34c99</div><div><br></div><div>╰─$ \
/usr/local/pgsql/bin/pg_ctl -D test-db -l logfile restart<br>waiting for server to \
shut down.... done<br>server stopped<br>waiting for server to start.... \
done<br>server started                                                                \
<br>╭─~/src/postgres ‹849172ff48●›<br>╰─$ /usr/local/pgsql/bin/psql \
postgres<br>psql (17devel)<br>Type &quot;help&quot; for help.<br><br>postgres=# \
CREATE EXTENSION pgtam;<br>ERROR:   incompatible library \
&quot;/usr/local/pgsql/lib/pgtam.dylib&quot;: missing magic block<br>HINT:   \
Extension libraries are required to use the PG_MODULE_MAGIC \
macro.<br></div><div><br></div><div>What am I missing?</div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic