Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Visa Inquirer

    #1

    Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

    I need my program to always link to a particular shared library, not
    the one in LD_LIBRARY_PATH .

    Is there a way to specify shared library by full path when linking so
    that when running LD_LIBRARY_PATH is ignored?
  • Ian Collins

    #2
    Re: Linking with a particular shared library by full path overridingLD_LI BRARY_PATH

    Visa Inquirer wrote:
    I need my program to always link to a particular shared library, not
    the one in LD_LIBRARY_PATH .
    >
    LD_LIBRARY_PATH is both evil and off topic. Try comp.unix.progr ammer.

    --
    Ian Collins.

    Comment

    • Gordon Burditt

      #3
      Re: Linking with a particular shared library by full path overridingLD_LI BRARY_PATH

      >Beyond that... well, it would probably be better for you to ask in
      >a forum that has an idea of what LD_LIBRARY_PATH is. LD_LIBRARY_PATH
      >is not part of standard C, and is very unlikely to become part of
      >standard C (the name conflicts with the namespace reserved for
      >user programs).
      The name conflicts in *WHAT* namespace? I don't see any place
      in the C standard where environment variable names are reserved for
      user programs.

      Comment

      • Antoninus Twink

        #4
        Re: Linking with a particular shared library by full path overriding LD_LIBRARY_PATH

        On 10 Apr 2008 at 21:11, Visa Inquirer wrote:
        I need my program to always link to a particular shared library, not
        the one in LD_LIBRARY_PATH .
        >
        Is there a way to specify shared library by full path when linking so
        that when running LD_LIBRARY_PATH is ignored?
        You can set the program's rpath: this will hard code a dynamic library
        search path into your binary, and on most systems this will override
        LD_LIBRARY_PATH .

        With gcc, you can provide
        -rpath dir
        as an option when linking, and this will add dir to the executable's
        run-time link path.

        You should be aware that setting the rpath can cause all sorts of
        problems if your program is installed by people who want to install
        their libraries somewhere other than your preferred hard-coded search
        path.

        Comment

        • Walter Roberson

          #5
          Re: Linking with a particular shared library by full path overridingLD_LI BRARY_PATH

          In article <ssSdnQreJuztEG PanZ2dnUVZ_ofin Z2d@internetame rica>,
          Gordon Burditt <gordonb.je2j0@ burditt.orgwrot e:
          >>Beyond that... well, it would probably be better for you to ask in
          >>a forum that has an idea of what LD_LIBRARY_PATH is. LD_LIBRARY_PATH
          >>is not part of standard C, and is very unlikely to become part of
          >>standard C (the name conflicts with the namespace reserved for
          >>user programs).
          >The name conflicts in *WHAT* namespace? I don't see any place
          >in the C standard where environment variable names are reserved for
          >user programs.
          The original poster made no indication that LD_LIBRARY_PATH was
          an environment variable, only that it was a name whose value
          the poster wished to be ignored.

          --
          "Not the fruit of experience, but experience itself, is the end."
          -- Walter Pater

          Comment

          • Walter Roberson

            #6
            Re: Linking with a particular shared library by full path overriding LD_LIBRARY_PATH

            In article <slrnfvt4fr.vaf .nospam@nospam. invalid>,
            Antoninus Twink <nospam@nospam. invalidwrote:
            >On 10 Apr 2008 at 21:11, Visa Inquirer wrote:
            >I need my program to always link to a particular shared library, not
            >the one in LD_LIBRARY_PATH .
            >>
            >Is there a way to specify shared library by full path when linking so
            >that when running LD_LIBRARY_PATH is ignored?
            >You can set the program's rpath: this will hard code a dynamic library
            >search path into your binary, and on most systems this will override
            >LD_LIBRARY_PAT H.
            Most systems? I dunno about that. Certainly not on the system I'm
            using now -- here the -rpath ld option *adds* the given directory
            to the search path, but does not override LD_LIBRARY_PATH (or the
            system variations therein such as LD_LIBRARY64_PA TH). On the system
            I'm using, you have to link with -no_library_repl ace to prevent
            the path specified in the binary from being overridden.
            --
            "There's no term to the work of a scientist." -- Walter Reisch

            Comment

            Working...