Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Linking CPAN modules to specific library

by ewedaa (Initiate)
on May 15, 2018 at 18:02 UTC ( [id://1214575]=perlquestion: print w/replies, xml ) Need Help??

ewedaa has asked for the wisdom of the Perl Monks concerning the following question:

I'm having an interesting problem compiling a CPAN module (Net::SSLeay in particular). This particular module creates a binary library, SSLeay.so. For various reasons, I have to make/compile this module by hand.

The problem I am having is that the prior admins never "really" updated this particular system, and instead created a new directory /usr/local/ssl/ssl_version and installed new versions of ssl into that directory tree, and then passed the proper path to Apache and other programs when they compiled/installed the new versions. There are assorted "bad" versions of libssl scattered around the system being used by assorted programs (I'm working on cleaning those up too.)

I was able to edit the Makefile to get rid of /usr/lib/ and /usr/lib64. I even added the path I want into the Makefile as

LDDLFLAGS = -shared -O2 -L/usr/local/DPS/openssl/openssl-1.0.1m -L/lib + -L/usr -L/usr/local/lib -fstack-protector LDFLAGS = -fstack-protector -L/usr/local/DPS/openssl/openssl-1.0.1m - +L/usr -L/usr/local/lib EXTRALIBS = -L/usr/local/DPS/openssl/openssl-1.0.1m -L/usr -L/lib - +lssl -lcrypto -lz LDLOADLIBS = -L/usr/local/DPS/openssl/openssl-1.0.1m -L/usr -L/lib +-lssl -lcrypto -lz

But it still links to the bad version in /lib.

Any ideas on how to force it to force it to link to the version I want at /usr/local/DPS/openssl/openssl-1.0.1m

(I'm sure it's something stupid...)

Thanks!

Replies are listed 'Best First'.
Re: Linking CPAN modules to specific library
by Corion (Patriarch) on May 15, 2018 at 18:20 UTC

    Maybe listing the directories and the libraries immediately next to each other forces the linker to pick up the correct libssl.lib?

    LDDLFLAGS = -shared -O2 -L/usr/local/DPS/openssl/openssl-1.0.1m -L/lib + -L/usr -L/usr/local/lib -fstack-protector LDFLAGS = -fstack-protector -L/usr/local/DPS/openssl/openssl-1.0.1m - +L/usr -L/usr/local/lib EXTRALIBS = -L/usr/local/DPS/openssl/openssl-1.0.1m -lssl -lcrypto -L +/usr -L/lib -lz LDLOADLIBS = -L/usr/local/DPS/openssl/openssl-1.0.1m -lssl -lcrypto - +L/usr -L/lib -lz
Re: Linking CPAN modules to specific library
by Anonymous Monk on May 15, 2018 at 20:09 UTC

    There may be two separate problems. One, how the makefile flags and environment influence which libraries are linked against. See ld. Second, how the system finds libraries at runtime. See ld.so.

    • You could have a LD_LIBRARY_PATH environment variable set up in the working environment. But this can be fragile.
    • The /etc/ld.so.conf could be edited to contain your library directories.
    • Some old libtool file /usr/lib/*.la could influence your build environment, adding incorrect link options.
    • When building, you can pass linker flags through the compiler, such as -Wl,-rpath,/path/to/custom/libraries.

    In any case, it looks like you are dealing with a mess. How to best clean it up depends on what options you have available as an admin.

Re: Linking CPAN modules to specific library
by Anonymous Monk on May 16, 2018 at 01:14 UTC
    In the Linux world, libraries are listed in /etc/ld.so.conf and indexed by /sbin/ldconfig. Your predecessor might have fiddled with those directory-lists as well, doing non-standard things. If you change the conf file, you must re-run the indexer (as root).
Re: Linking CPAN modules to specific library
by ewedaa (Initiate) on Jun 26, 2018 at 18:48 UTC

    Somebody else found it for me

    It's in the README file, but I have no idea why when I googoled this the README didn't show up.</>

    If your OpenSSL is installed in an unusual place, you can tell Net-SSLeay where to find it with the OPENSSL_PREFIX environment variable:

    OPENSSL_PREFIX=/home/mikem/playpen/openssl-1.0.2c perl Makefile.PL

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1214575]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found