pgxs question - linking c-functions to external libraries

Started by Nonamealmost 18 years ago10 messagesgeneral
Jump to latest
#1Noname
johnduffy@f2s.com

Hi

I have written a number of C-Function which compile and link against the GNU
Scientific Library libraries 'libgsl' and 'libgslcblas' when using a hand
written Makefile, but I would like to use PGXS.

My functions compile fine using PGXS, but don't link against the GSL libraries.
How do I specify the GSL libraries as external libraries to link against in the
PGXS Makfile? I have tried the following which don't work:

PG_CPPFLAGS = -lgsl -lgslcblas
PG_LIBS = -lgsl -gslcblas
SHLIB_LINK = -lgsl -gslcblas

My PGXS makefile is:

MODULES pg_gsl
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

Many thanks
John

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: pgxs question - linking c-functions to external libraries

johnduffy@f2s.com writes:

My functions compile fine using PGXS, but don't link against the GSL libraries.
How do I specify the GSL libraries as external libraries to link against in the
PGXS Makfile? I have tried the following which don't work:

PG_CPPFLAGS = -lgsl -lgslcblas
PG_LIBS = -lgsl -gslcblas
SHLIB_LINK = -lgsl -gslcblas

My PGXS makefile is:

MODULES pg_gsl
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

SHLIB_LINK is the right thing for MODULES. Maybe you forgot a -L
switch?

regards, tom lane

#3Noname
johnduffy@f2s.com
In reply to: Tom Lane (#2)
Re: pgxs question - linking c-functions to external libraries

Tom

Thanks for the reply. My GSL libraries, 'libgsl' and 'libgslcblas', are in the
/usr/lib directory as GSL and the GSL development files were installed via
Fedora 8 RPM's. I'm a relative newbie to programming, so I thought the -L
switch is only required to add a non-standard library location to the
directories searched for libraries.

I will give it a go.

Thanks

John

Quoting Tom Lane <tgl@sss.pgh.pa.us>:

Show quoted text

johnduffy@f2s.com writes:

My functions compile fine using PGXS, but don't link against the GSL

libraries.

How do I specify the GSL libraries as external libraries to link against in

the

PGXS Makfile? I have tried the following which don't work:

PG_CPPFLAGS = -lgsl -lgslcblas
PG_LIBS = -lgsl -gslcblas
SHLIB_LINK = -lgsl -gslcblas

My PGXS makefile is:

MODULES pg_gsl
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

SHLIB_LINK is the right thing for MODULES. Maybe you forgot a -L
switch?

regards, tom lane

#4Martijn van Oosterhout
kleptog@svana.org
In reply to: Noname (#3)
Re: pgxs question - linking c-functions to external libraries

On Mon, May 19, 2008 at 06:23:03PM +0100, johnduffy@f2s.com wrote:

Thanks for the reply. My GSL libraries, 'libgsl' and 'libgslcblas', are in the

I saw that and then in your previous message:

PG_CPPFLAGS = -lgsl -lgslcblas
PG_LIBS = -lgsl -gslcblas
SHLIB_LINK = -lgsl -gslcblas

Shouldn't those -gslcblas be -lgslcblas?

Have a ncie day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Please line up in a tree and maintain the heap invariant while
boarding. Thank you for flying nlogn airlines.

#5Noname
johnduffy@f2s.com
In reply to: Martijn van Oosterhout (#4)
Re: pgxs question - linking c-functions to external libraries

A typo on my part in my posting. My Makefile has:

SHLIB_LINK = -lgsl -lgslcblas

Regards

John

Quoting Martijn van Oosterhout <kleptog@svana.org>:

Show quoted text

On Mon, May 19, 2008 at 06:23:03PM +0100, johnduffy@f2s.com wrote:

Thanks for the reply. My GSL libraries, 'libgsl' and 'libgslcblas', are in

the

I saw that and then in your previous message:

PG_CPPFLAGS = -lgsl -lgslcblas
PG_LIBS = -lgsl -gslcblas
SHLIB_LINK = -lgsl -gslcblas

Shouldn't those -gslcblas be -lgslcblas?

Have a ncie day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Please line up in a tree and maintain the heap invariant while
boarding. Thank you for flying nlogn airlines.

#6Rad Cirskis
rad.cirskis@endace.com
In reply to: Noname (#1)

Hi John,
have you managed to get it to link with external shared libs?
tia,
Rad

________________________________
Rad Cirskis
Senior Software Engineer
Level 2, Building A, The Millennium Building Phase 2, 600 Great South Road, Ellerslie
Auckland City, Auckland, 1051
+64 9 926 2891 Office
www.emulex.com
[http://www.emulex.com/files/signature/emulexendacelogo.jpg] <http://www.emulex.com/emulex-connects/&gt;
This message contains Emulex confidential information intended only for specific recipients and is not to be forwarded to anyone else. If you have received this message in error, please delete it immediately. Thank you.

#7Peter Eisentraut
peter_e@gmx.net
In reply to: Rad Cirskis (#6)
Re: pgxs question - linking c-functions to external libraries

On 6/6/13 11:49 PM, Rad Cirskis wrote:

Hi John,
have you managed to get it to link with external shared libs?

Sure, many extensions to that. Do something like

SHLIB_LINK += -lfoo

in your Makefile.

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

#8Alan Nilsson
anilsson@apple.com
In reply to: Peter Eisentraut (#7)
Re: pgxs question - linking c-functions to external libraries

I recently had need to do the same thing and I am having no luck. Admittedly, I am not too keen on the postgres build setup and have not debugged this extensively, but rather hoped there was an easy answer up front. That said….

I am trying to link libuuid into a custom extension, here is my make file (building PG 9.3.5 on CentOS 6.5 (GCC 4.4.7) fwiw):

MODULES = aitpowerpg
EXTENSION = aitpowerpg
DATA = aitpowerpg--1.0.sql

SHLIB_LINK += -luuid

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/aitpowerpg
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

The line SHLIB_LINK += -luuid has no effect. All of postgres builds & runs ok, this custom module builds fine but won’t load due to missing symbols which makes sense since ldd shows that libuuid is not linked in.

If I make clean, make, then just execute the last gcc invocation to link the extension then manually tack -luuid at the end, all is good.

Is there something simple I’m missing?

thanks
alan

Show quoted text

On Jun 19, 2013, at 6:57 AM, Peter Eisentraut <peter_e@gmx.net> wrote:

On 6/6/13 11:49 PM, Rad Cirskis wrote:

Hi John,
have you managed to get it to link with external shared libs?

Sure, many extensions to that. Do something like

SHLIB_LINK += -lfoo

in your Makefile.

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

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alan Nilsson (#8)
Re: pgxs question - linking c-functions to external libraries

Alan Nilsson <anilsson@apple.com> writes:

I am trying to link libuuid into a custom extension, here is my make file (building PG 9.3.5 on CentOS 6.5 (GCC 4.4.7) fwiw):

MODULES = aitpowerpg
EXTENSION = aitpowerpg
DATA = aitpowerpg--1.0.sql

SHLIB_LINK += -luuid

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/aitpowerpg
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

The line SHLIB_LINK += -luuid has no effect.

I'm not sure how well documented this is, but pgxs.mk quoth

# SHLIB_LINK -- will be added to MODULE_big link line

Since you're using the MODULES target not the MODULE_big target, it gets
left out. Try following the pattern in the contrib/uuid-ossp Makefile.

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

#10Alan Nilsson
anilsson@apple.com
In reply to: Tom Lane (#9)
Re: pgxs question - linking c-functions to external libraries

Awesome - thanks Tom, works.

alan

On Dec 12, 2014, at 1:06 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Alan Nilsson <anilsson@apple.com> writes:

I am trying to link libuuid into a custom extension, here is my make file (building PG 9.3.5 on CentOS 6.5 (GCC 4.4.7) fwiw):

MODULES = aitpowerpg
EXTENSION = aitpowerpg
DATA = aitpowerpg--1.0.sql

SHLIB_LINK += -luuid

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/aitpowerpg
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

The line SHLIB_LINK += -luuid has no effect.

I'm not sure how well documented this is, but pgxs.mk quoth

# SHLIB_LINK -- will be added to MODULE_big link line

Since you're using the MODULES target not the MODULE_big target, it gets
left out. Try following the pattern in the contrib/uuid-ossp Makefile.

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