Reputation: 13677
I have a Perl library that consists of a C library in a binary form (.so
file) and sources for Perl bindings for that library (Makefile.PL
etc).
All I need is an ability to run Perl samples shipped with the library. I'd like to avoid installing anything globally or changing system-wide configs.
So I created a special user and I want everything to run inside the home dir. Changing environment and adding files/folders in the homedir is fine of course.
I already have local::lib
and various CPAN helpers installed system-wide (cpan
, cpanp
and cpanm
so I can use them if they are of any help.
I could create ~/lib
and put .so
there, or put it somewhere inside ~/perl5
.
The question is how to make the shared C library available to the Perl bindings during compilation and during runtime. It seems I need LD_LIBRARY_PATH
and LDFLAGS
environment variables but I'm not sure how to use them together with local::lib
.
Moreover the library comes named as foo.1.2.3.4.so
but linker wants -lfoo
. Am I supposed to create foo.so -> foo.1.2.3.4.so
symlink myself?
Upd:
The relevant part of generated Makefile
:
LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
$(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
$(INST_DYNAMIC_FIX)
Patching LDDLFLAGS to include an extra -L
switch works but feels dirty.
Upvotes: 1
Views: 110