pgxs "missing magic block ... PG_MODULE_MAGIC" with "MODULE_big"

Started by David Fuhryover 13 years ago4 messagesgeneral
Jump to latest
#1David Fuhry
dfuhry@gmail.com

Hi, I'm trying to add a C-Language function but getting the following error:

$ psql -f test_cfunc.sql
psql:test_cfunc.sql:3: ERROR: incompatible library
"/usr/local/pgsql/lib/test_cfunc.so": missing magic block
HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.

I am calling PG_MODULE_MAGIC in my c file. Minimal Makefile, .c, and .sql
files are attached. In the Makefile, if I change "MODULE_big" to "MODULES",
it works. However, I want to use "MODULE_big" because I need to later link
to a shared library using SHLIB_LINK, and "MODULES" doesn't support
SHLIB_LINK as per
http://archives.postgresql.org/pgsql-hackers/2012-03/msg00537.php

Any suggestions on how I can get PG_MODULE_MAGIC to work with "MODULE_big"
(or link a shared library when using "MODULES")?

Thanks,

Dave

Attachments:

Makefileapplication/octet-stream; name=MakefileDownload
test_cfunc.ctext/x-csrc; charset=US-ASCII; name=test_cfunc.cDownload
test_cfunc.sqlapplication/octet-stream; name=test_cfunc.sqlDownload
#2David Fuhry
dfuhry@gmail.com
In reply to: David Fuhry (#1)
Re: pgxs "missing magic block ... PG_MODULE_MAGIC" with "MODULE_big"

Forgot to mention, I am on 9.2.1. "SELECT version();" reports:

PostgreSQL 9.2.1 on x86_64-unknown-linux-gnu, compiled by gcc (Debian
4.4.5-8) 4.4.5, 64-bit

-Dave

On Tue, Jan 8, 2013 at 12:30 PM, David Fuhry <dfuhry@gmail.com> wrote:

Show quoted text

Hi, I'm trying to add a C-Language function but getting the following
error:

$ psql -f test_cfunc.sql
psql:test_cfunc.sql:3: ERROR: incompatible library
"/usr/local/pgsql/lib/test_cfunc.so": missing magic block
HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.

I am calling PG_MODULE_MAGIC in my c file. Minimal Makefile, .c, and .sql
files are attached. In the Makefile, if I change "MODULE_big" to "MODULES",
it works. However, I want to use "MODULE_big" because I need to later link
to a shared library using SHLIB_LINK, and "MODULES" doesn't support
SHLIB_LINK as per
http://archives.postgresql.org/pgsql-hackers/2012-03/msg00537.php

Any suggestions on how I can get PG_MODULE_MAGIC to work with "MODULE_big"
(or link a shared library when using "MODULES")?

Thanks,

Dave

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fuhry (#1)
Re: pgxs "missing magic block ... PG_MODULE_MAGIC" with "MODULE_big"

David Fuhry <dfuhry@gmail.com> writes:

Hi, I'm trying to add a C-Language function but getting the following error:
$ psql -f test_cfunc.sql
psql:test_cfunc.sql:3: ERROR: incompatible library
"/usr/local/pgsql/lib/test_cfunc.so": missing magic block
HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.

I am calling PG_MODULE_MAGIC in my c file. Minimal Makefile, .c, and .sql
files are attached. In the Makefile, if I change "MODULE_big" to "MODULES",
it works. However, I want to use "MODULE_big" because I need to later link
to a shared library using SHLIB_LINK, and "MODULES" doesn't support
SHLIB_LINK as per
http://archives.postgresql.org/pgsql-hackers/2012-03/msg00537.php

I think you're missing the OBJS line, with the result that the .so ends
up empty.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4David Fuhry
dfuhry@gmail.com
In reply to: Tom Lane (#3)
Re: pgxs "missing magic block ... PG_MODULE_MAGIC" with "MODULE_big"

Thank you Tom, you are correct. Adding the line:

OBJS = test_cfunc.o

to the Makefile resolved the problem.

-Dave

On Tue, Jan 8, 2013 at 12:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

David Fuhry <dfuhry@gmail.com> writes:

Hi, I'm trying to add a C-Language function but getting the following

error:

$ psql -f test_cfunc.sql
psql:test_cfunc.sql:3: ERROR: incompatible library
"/usr/local/pgsql/lib/test_cfunc.so": missing magic block
HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.

I am calling PG_MODULE_MAGIC in my c file. Minimal Makefile, .c, and .sql
files are attached. In the Makefile, if I change "MODULE_big" to

"MODULES",

it works. However, I want to use "MODULE_big" because I need to later

link

to a shared library using SHLIB_LINK, and "MODULES" doesn't support
SHLIB_LINK as per
http://archives.postgresql.org/pgsql-hackers/2012-03/msg00537.php

I think you're missing the OBJS line, with the result that the .so ends
up empty.

regards, tom lane