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
libpqjust because it might not be available on all systems.What you should generally do instead is dynamically link to
libqand either setLD_LIBRARY_PATHin a wrapper script or userpathlinking so thatlibpqcan be found.Be aware though that whether statically or dynamically linking, if some other module loads a
libpqinto the same Perl you'll either get two incompatiblelibpqs linked into the same executable (boom) or one of the modules using alibpqother 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_PATHwill almost certainly cause issues.You might want to look into using
rpathwith$ORIGIN.