Thread: pgxs question - linking c-functions to external libraries
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
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
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>: > 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 > >
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.
Attachment
A typo on my part in my posting. My Makefile has: SHLIB_LINK = -lgsl -lgslcblas Regards John Quoting Martijn van Oosterhout <kleptog@svana.org>: > 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. >
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
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.
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

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.
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.
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
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
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
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