I'm trying to build DBD::Pg on a linux host via the Makefile.PL; my requirements are such that I must be able to dynamically link against perl, but statically link against libpq.so (since it may not be available on all boxes).
Is there an easy way to do this? I have tried changing the link options in the LIBS directive of the Makefile.PL but MakeMaker ignores my options.
IMO you've mis-specified your requirements.
You do not need to statically link to
libpq
just because it might not be available on all systems.What you should generally do instead is dynamically link to
libq
and either setLD_LIBRARY_PATH
in a wrapper script or userpath
linking so thatlibpq
can be found.Be aware though that whether statically or dynamically linking, if some other module loads a
libpq
into the same Perl you'll either get two incompatiblelibpq
s linked into the same executable (boom) or one of the modules using alibpq
other than the one it was compiled against (also boom). If you use rpath linking,ld.so
's awareness of link scopes might let you get away with it, but settingLD_LIBRARY_PATH
will almost certainly cause issues.You might want to look into using
rpath
with$ORIGIN
.