<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: shared libraries and $ORIGIN in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452513#M848909</link>
    <description>the missing slash does not seem to be a problem, the loader is putting in a /-terminated string in place of $ORIGIN.&lt;BR /&gt;&lt;BR /&gt;there is very little documentation yet which i can point you to. i will make sure that something is done about it.&lt;BR /&gt;&lt;BR /&gt;there is no limit to the number of occurences of "$ORIGIN", you can use as many as you want.&lt;BR /&gt;&lt;BR /&gt;the loader will replace all instances of $ORIGIN in all embedded paths (executable and shared libraries). consider this case:&lt;BR /&gt;a.out-&amp;gt;libx.sl-&amp;gt;liby.sl-&amp;gt;libz.sl&lt;BR /&gt;when libz.sl is loaded because of liby.sl, the search path will include all the embedded paths of a.out, libx.sl and liby.sl.&lt;BR /&gt;&lt;BR /&gt;so you could have a.out having "$ORIGIN/../lib" in its embedded path and shared libraries having "$ORIGIN" in theirs.&lt;BR /&gt;&lt;BR /&gt;as far as i know, no other platform has the shl_* api's, so i think it could not have been working in linux.</description>
    <pubDate>Mon, 10 Jan 2005 06:49:11 GMT</pubDate>
    <dc:creator>ranganath ramachandra</dc:creator>
    <dc:date>2005-01-10T06:49:11Z</dc:date>
    <item>
      <title>shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452504#M848900</link>
      <description>&lt;BR /&gt;RE: shared libraries&lt;BR /&gt;&lt;BR /&gt;We have software that runs on different vendors platforms. For HP-UX we want to use shared libraries with each library in a different directory.&lt;BR /&gt;&lt;BR /&gt;Consider the following example which are programs extracted and modified from the HP-UX Linker and Libraries and User.s Guide. There are three programs, testlibfoo3.c, libfoo.c and libfoo2.c. The sequence in running the programs is:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;1) testlibfoo3 in directory mydirA loads shared library libfoo.sl in mydirB and executes code&lt;BR /&gt;in libfoo.sl&lt;BR /&gt;2) libfoo loads shared library libfoo2 in mydirB, executes code in libfoo2, then unloads libfoo2.&lt;BR /&gt;3) testlibfoo3 unloads shared library libfoo.sl&lt;BR /&gt;&lt;BR /&gt;Below is a description of  what we did, but it may be easier to say how to do it correctly instead of finding error(s) in the way we tried to do this.&lt;BR /&gt;&lt;BR /&gt;We think part of the code to do this can use the $ORIGIN option from the linker, ld.&lt;BR /&gt;The  code to reproduce the problem we see is in the attachment of appendices to this note. The code for testlibfoo3, libfoo.c and libfoo2.c is in Appendices I, II and III, respectively. The code to compile, link and run&lt;BR /&gt;each of them is contained as comments in each of the appendices.&lt;BR /&gt;&lt;BR /&gt;If the three files are in the same directory are compiled and linked then testlibfoo3 runs correctly.&lt;BR /&gt;I do this first to be sure the files are compiled and linked correctly.&lt;BR /&gt;&lt;BR /&gt;The man page for ld says more information on the $ORIGIN option is available in the HP-UX Linker and Libraries User.s Guide. I looked in the HP-UX Linker and Libraries User.s Guide, document B2355-90655, November 1997, and do not understand how to use $ORIGIN.&lt;BR /&gt;&lt;BR /&gt;I did see the man page for ld has a typo in the example:&lt;BR /&gt;   $ ld  -dynamic main.o -L /usr/lib/ -lc +B $ORIGIN&lt;BR /&gt;in which "+B" should  be "+b"&lt;BR /&gt;&lt;BR /&gt;My testing was done in the tcsh shell with these environment variables:&lt;BR /&gt;&lt;BR /&gt;[qa00hpu:/home/hrutieze/bugs/dlopen/ex7/mydirA]536 % env | egrep 'ORIGIN|SHLIB_PATH'&lt;BR /&gt;SHLIB_PATH=./&lt;BR /&gt;ORIGIN=./&lt;BR /&gt;&lt;BR /&gt;This what I saw from in running a.out&lt;BR /&gt;&lt;BR /&gt;[qa00hpu:/home/hrutieze/bugs/dlopen/ex8/mydirA]822 % ./a.out&lt;BR /&gt;- Version 0.4&lt;BR /&gt;- testlibfoo3: Use shl_load for shared library libfoo.sl&lt;BR /&gt;- testlibfoo3: Error loading libfoo.sl: No such file or directory&lt;BR /&gt;&lt;BR /&gt;This same information is contained in the attachment.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Howard&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Dec 2004 15:46:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452504#M848900</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2004-12-29T15:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452505#M848901</link>
      <description>this is how the $ORIGIN thing works:&lt;BR /&gt;&lt;BR /&gt;you put "$ORIGIN" (literally) in the embedded path (through +b, not sure if it works for path recorded through +cdp) at link time. at load-time (run-time), the loader will substitute "$ORIGIN" with the full path of the directory where the current load module (executable or shared library) was loaded from.&lt;BR /&gt;&lt;BR /&gt;suppose you used a link line like&lt;BR /&gt;&lt;BR /&gt;ld -b x.o -o libx.sl +b \$ORIGIN -ly&lt;BR /&gt;&lt;BR /&gt;if, in a process, libx.sl  was loaded from /usr/local/lib, then the loader will look for liby.sl in /usr/local/lib.&lt;BR /&gt;&lt;BR /&gt;a typical example: suppose you ship application programs and binaries such that the programs reside in &lt;BASEDIR&gt;/bin and libraries are in &lt;BASEDIR&gt;/lib, where basedir is a base directory that the installing user can choose. you could build an application with a link line like&lt;BR /&gt;&lt;BR /&gt;ld *.o -o app -lx ...  +b \$ORIGIN/../lib&lt;BR /&gt;&lt;BR /&gt;so that regardless of which base directory your application program and binaries are installed in, libx.sl (etc) can be picked from the neighbouring 'lib' directory.&lt;BR /&gt;&lt;BR /&gt;make sure you follow proper shell/makefile syntax (wrt escape characters etc) to get the string "$ORIGIN" (without the quotes, of course) into the embedded path.&lt;/BASEDIR&gt;&lt;/BASEDIR&gt;</description>
      <pubDate>Thu, 30 Dec 2004 02:35:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452505#M848901</guid>
      <dc:creator>ranganath ramachandra</dc:creator>
      <dc:date>2004-12-30T02:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452506#M848902</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;I included an attachment as a text file that&lt;BR /&gt;got mangled. The text file contains my description and a reproducer, containing the three files testlibfoo3.c, libfoo.c, libfoo2.c, as Appendices I, II and III. Will try the attachment again as a Microsoft Word file. &lt;BR /&gt;&lt;BR /&gt;The command used in testing is &lt;BR /&gt; cc -g -O0 -Wl,+b \$ORIGIN:\$ORIGIN../mydirB testlibfoo3.c&lt;BR /&gt;&lt;BR /&gt;chatr of a.out shows:&lt;BR /&gt;a.out:&lt;BR /&gt;         shared executable&lt;BR /&gt;         shared library dynamic path search:&lt;BR /&gt;             SHLIB_PATH     enabled   first&lt;BR /&gt;             embedded path  enabled   second $ORIGIN:$ORIGIN../mydirB&lt;BR /&gt;         shared library list:&lt;BR /&gt;             dynamic   /usr/lib/libc.2&lt;BR /&gt;   [ ... deleted lines ... ]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and environments are set this way and a.out is in directory mydirA&lt;BR /&gt;% env  | egrep  â  SHLIB_PATH|ORIGINâ  &lt;BR /&gt;SHLIB_PATH=./&lt;BR /&gt;ORIGIN</description>
      <pubDate>Thu, 30 Dec 2004 09:28:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452506#M848902</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2004-12-30T09:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452507#M848903</link>
      <description>&lt;BR /&gt;Bad character again at end of post&lt;BR /&gt;Dec 30, 2004 14:28:53 GMT  &lt;BR /&gt;although it did not look that way to me when&lt;BR /&gt;I did it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;% env | egrep 'SHLIB_PATH|ORIGIN'&lt;BR /&gt;SHLIB_PATH=./&lt;BR /&gt;ORIGIN=./ &lt;BR /&gt;&lt;BR /&gt;Is there is a reference to HP documentation that completely explains how to use $ORIGIN? &lt;BR /&gt;&lt;BR /&gt;I found incomplete documentation in the man page for ld and in the HP-UX Linker and Libraries User's Guide, HP 9000 Computers, document B2355-90655, November 1997, as described in the attachment with the prior posting.&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 30 Dec 2004 09:48:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452507#M848903</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2004-12-30T09:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452508#M848904</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;I've gotten a little bit further.&lt;BR /&gt;If in the shl_load in testlibfoo3 one adds the flag DYNAMIC_PATH to this statement&lt;BR /&gt;  if ((hndl_foo1 =&lt;BR /&gt;    shl_load("libfoo.sl", &lt;BR /&gt;    BIND_IMMEDIATE |BIND_VERBOSE|DYNAMIC_PATH,0)) == NULL)&lt;BR /&gt;&lt;BR /&gt;then the program gets a bit further, it &lt;BR /&gt;loads libfoo.sl. &lt;BR /&gt;&lt;BR /&gt;Let me look a little further into this after the holiday weekend. I think libfoo which is supposed to load libfoo2 does not use DYNAMIC_PATH and I will change that when I try again.&lt;BR /&gt;&lt;BR /&gt;Let's put this on hold for now.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Howard&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Dec 2004 16:21:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452508#M848904</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2004-12-31T16:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452509#M848905</link>
      <description>&lt;BR /&gt;Continuing on with tests ...&lt;BR /&gt;&lt;BR /&gt;See the attachemt again --&lt;BR /&gt;&lt;BR /&gt;- Did NOT get $ORIGIN with embedded path to work. &lt;BR /&gt;- Did get SHLIB_PATH to work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Testing was done with SHLIB_PATH set in each of these two ways:&lt;BR /&gt;&lt;BR /&gt;When I used this SHLIB_PATH where "./" is "mydirA"&lt;BR /&gt; &lt;BR /&gt; SHLIB_PATH=./:./../mydirB&lt;BR /&gt;&lt;BR /&gt;the test ran successfully.&lt;BR /&gt;I think because dld.sl found the libraries to be loaded along the search path &lt;BR /&gt;specified by SHLIB_PATH.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I changed this same environment variable to&lt;BR /&gt; SHLIB_PATH=./&lt;BR /&gt;the test hung trying to shl_load "libfoo.sl".&lt;BR /&gt;&lt;BR /&gt;When I use a non-existent directory like&lt;BR /&gt; SHLIB_PATH=./:./../mydirX&lt;BR /&gt;the tests hang as in the previous case.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you look at appendix I, you can see libtestfoo3.c was compiled with&lt;BR /&gt;&lt;BR /&gt; cc -g -O0 -Wl,+b \$ORIGIN:\$ORIGIN../mydirB testlibfoo3.c&lt;BR /&gt;&lt;BR /&gt;and that "chatr a.out" show the embedded path:&lt;BR /&gt;&lt;BR /&gt;a.out:&lt;BR /&gt; shared executable&lt;BR /&gt; shared library dynamic path search:&lt;BR /&gt;   SHLIB_PATH     enabled   first&lt;BR /&gt;   embedded path  enabled   second     $ORIGIN:$ORIGIN../mydirB&lt;BR /&gt;         shared library list:&lt;BR /&gt;             dynamic   /usr/lib/libc.2&lt;BR /&gt;&lt;BR /&gt;    [ ... deleted lines ... ]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The directory structure for the testing is&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                |&lt;BR /&gt;     mydirA     |      mydirB&lt;BR /&gt;      +---------+-------+&lt;BR /&gt;      |                 |&lt;BR /&gt;      |                 |&lt;BR /&gt;     a.out        libfoo.sl, libfoo2.sl&lt;BR /&gt;   created        created from libfoo.c and &lt;BR /&gt;    from          libfoo2.c, respectively&lt;BR /&gt;  testlibfoo3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The C code is &lt;BR /&gt;&lt;BR /&gt;if ((hndl_foo1 = shl_load("libfoo.sl", &lt;BR /&gt;BIND_IMMEDIATE|BIND_VERBOSE|DYNAMIC_PATH,0)) == NULL)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This was tested with:&lt;BR /&gt;&lt;BR /&gt;cpp.ansi: HP92453-01 B.11.11.06 HP C Preprocessor (ANSI)&lt;BR /&gt;ccom: HP92453-01 B.11.11.06 HP C Compiler&lt;BR /&gt;/usr/ccs/bin/ld: 92453-07 linker linker ld B.11.30 011005&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Am I compiling or linking the program incorrectly?&lt;BR /&gt;&lt;BR /&gt;As Ranganath says, "at load-time (run-time), the loader will substitute '$ORIGIN' with the full path of the directory where the current load module (executable or shared library) was loaded from." for both occurances of $ORIGIN ?&lt;BR /&gt;&lt;BR /&gt;If so, why does this fail given the dirctory&lt;BR /&gt;structure shown above? And why hang instead&lt;BR /&gt;of returning with an error?&lt;BR /&gt;&lt;BR /&gt;A different problem?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2005 13:21:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452509#M848905</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2005-01-05T13:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452510#M848906</link>
      <description>I might be on the wrong track but it seems to me that you are missing additional slash character when linking.&lt;BR /&gt;&lt;BR /&gt;You seem to currently have&lt;BR /&gt;&lt;BR /&gt;+b \$ORIGIN../mydirB&lt;BR /&gt;&lt;BR /&gt;Try linking with&lt;BR /&gt;&lt;BR /&gt;+b \$ORIGIN/../mydirB</description>
      <pubDate>Wed, 05 Jan 2005 20:42:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452510#M848906</guid>
      <dc:creator>Ermin Borovac</dc:creator>
      <dc:date>2005-01-05T20:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452511#M848907</link>
      <description>i'm sorry for telling you so late: for explicitly loaded shared libraries, the $ORIGIN stuff works only if you use dlopen and not if you use shl_load. do you have a reason not to use (the more portable) dl* api instead ?&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;----&lt;BR /&gt;cat &amp;gt; main.c &amp;lt;&amp;lt; \!&lt;BR /&gt;#include &lt;DLFCN.H&gt;&lt;BR /&gt;main () {&lt;BR /&gt; void (*foo)();&lt;BR /&gt; void *dl = dlopen("liblib.sl", RTLD_LAZY);&lt;BR /&gt; if (!dl) {&lt;BR /&gt;  puts(dlerror());&lt;BR /&gt;  exit(1);&lt;BR /&gt; }&lt;BR /&gt; foo=dlsym(dl, "foo");&lt;BR /&gt; if (foo)&lt;BR /&gt;  foo();&lt;BR /&gt; dlclose(dl);&lt;BR /&gt; exit(0);&lt;BR /&gt;}&lt;BR /&gt;!&lt;BR /&gt;cat &amp;gt; lib.c &amp;lt;&amp;lt; \!&lt;BR /&gt;foo () { &lt;BR /&gt; puts("yo");&lt;BR /&gt;}&lt;BR /&gt;!&lt;BR /&gt;cc main.c -o main -ldld -Wl,+b,\$ORIGIN/../lib&lt;BR /&gt;cc -b lib.c -o liblib.sl&lt;BR /&gt;# mkdir bin&lt;BR /&gt;mv -f main bin&lt;BR /&gt;# mkdir lib&lt;BR /&gt;mv -f liblib.sl lib&lt;BR /&gt;bin/main&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;this works for me, at least with the latest linker/loader patch (PHSS_30967 for 11.00).&lt;/DLFCN.H&gt;</description>
      <pubDate>Thu, 06 Jan 2005 08:11:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452511#M848907</guid>
      <dc:creator>ranganath ramachandra</dc:creator>
      <dc:date>2005-01-06T08:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452512#M848908</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Ermin,&lt;BR /&gt;&lt;BR /&gt;Yes, as you said, a missing slash during &lt;BR /&gt;linking.&lt;BR /&gt;&lt;BR /&gt;Ranganath,&lt;BR /&gt;&lt;BR /&gt;I tried what you said and it worked as you &lt;BR /&gt;described.&lt;BR /&gt;&lt;BR /&gt;This is what I think happens:&lt;BR /&gt;The first program, "main", loads "foo" and &lt;BR /&gt;calls the module "foo" in it. &lt;BR /&gt; &lt;BR /&gt;Additional question:&lt;BR /&gt;How can the second loaded program, the shared library "foo", load a shared library "foo2" located in another directory, say "lib2" and call a module, say, "infoo2" in shared library foo2 using the $ORIGIN mechanism you showed in your post of 6-Jan? &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And then go on this way, each shared library, possibly in a different directory calling into a shared library that may be in another directory. At run-time the relative path locations of the shared libraries are known, relative to the first program run, &lt;BR /&gt;"bin/main", in your example.&lt;BR /&gt;&lt;BR /&gt;This software system of which this code is a part, runs on different vendors products. &lt;BR /&gt;I was told the reason "shl_load" is used is&lt;BR /&gt;historical, that is, it is used because "shl_load" was available at the&lt;BR /&gt;time and the dl* APIs were not.&lt;BR /&gt; &lt;BR /&gt;I saw one paragraph in the HP-UX Linker and Libraries User's Guide manual, but nothing on use of more than one occurance of $ORIGIN&lt;BR /&gt;in a pathlist. Something like your example:&lt;BR /&gt;  cc main.c -o main -ldld  \&lt;BR /&gt;  -Wl,+b,\$ORIGIN/../lib:\$ORIGIN/../lib2&lt;BR /&gt;It seems to work, but will the loader replace&lt;BR /&gt;each occurance of $ORIGIN with full path name&lt;BR /&gt;of the location of the executable or shared&lt;BR /&gt;library?&lt;BR /&gt;&lt;BR /&gt;Can you point me to documentation that describes use of $ORIGIN combined with the dl* APIs? I was initially told "shl_load" and $ORIGIN work together because someone&lt;BR /&gt;said they saw it in HP documentation -- I&lt;BR /&gt;don't know where -- and it worked on a&lt;BR /&gt;version of Linux.&lt;BR /&gt; &lt;BR /&gt;Thanks,&lt;BR /&gt;Howard&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Jan 2005 14:56:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452512#M848908</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2005-01-07T14:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452513#M848909</link>
      <description>the missing slash does not seem to be a problem, the loader is putting in a /-terminated string in place of $ORIGIN.&lt;BR /&gt;&lt;BR /&gt;there is very little documentation yet which i can point you to. i will make sure that something is done about it.&lt;BR /&gt;&lt;BR /&gt;there is no limit to the number of occurences of "$ORIGIN", you can use as many as you want.&lt;BR /&gt;&lt;BR /&gt;the loader will replace all instances of $ORIGIN in all embedded paths (executable and shared libraries). consider this case:&lt;BR /&gt;a.out-&amp;gt;libx.sl-&amp;gt;liby.sl-&amp;gt;libz.sl&lt;BR /&gt;when libz.sl is loaded because of liby.sl, the search path will include all the embedded paths of a.out, libx.sl and liby.sl.&lt;BR /&gt;&lt;BR /&gt;so you could have a.out having "$ORIGIN/../lib" in its embedded path and shared libraries having "$ORIGIN" in theirs.&lt;BR /&gt;&lt;BR /&gt;as far as i know, no other platform has the shl_* api's, so i think it could not have been working in linux.</description>
      <pubDate>Mon, 10 Jan 2005 06:49:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452513#M848909</guid>
      <dc:creator>ranganath ramachandra</dc:creator>
      <dc:date>2005-01-10T06:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452514#M848910</link>
      <description>&lt;BR /&gt;I was wrong about shl_load and Linux.&lt;BR /&gt;&lt;BR /&gt;I tried the example you gave in the post of 6-Jan-2005 and it works exactly as you said.&lt;BR /&gt;&lt;BR /&gt;I changed my example to use the dl* APIs and&lt;BR /&gt;still have a problem. The shared library, libfoo.sl, loading another shared library, libfoo2, to call a routine in it, fails.&lt;BR /&gt;&lt;BR /&gt;Could you extend your example of 6-Jan do this?    &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I put the embedded path in a.out with: &lt;BR /&gt;cc -g -O0 -DUSE_DLOPEN -Wl,+b,\$ORIGIN:\$ORIGIN/../mydirB testlibfoo3.c&lt;BR /&gt;&lt;BR /&gt;1) a.out did dlopen for libfoo.sl &lt;BR /&gt;2) dlsym to get symbol for routine foo&lt;BR /&gt;3) called foo in libfoo.sl&lt;BR /&gt;&lt;BR /&gt;This is the code segment in libfoo.sl:&lt;BR /&gt;&lt;BR /&gt;#ifdef USE_DLOPEN&lt;BR /&gt;  printf("-- libfoo: do dlopen for libfoo2.sl  \n" );&lt;BR /&gt;  void *han = dlopen("libfoo2.sl", RTLD_NOW);&lt;BR /&gt;  if ( !han ) {&lt;BR /&gt;    printf("-- libfoo: dlopen of libfoo2.sl failed - %s \n", dlerror() );&lt;BR /&gt;  assert(han != NULL);&lt;BR /&gt;  }&lt;BR /&gt;  else&lt;BR /&gt;    printf("-- libfoo: dlopen of libfoo2.sl succeeded \n" );&lt;BR /&gt;&lt;BR /&gt;was compiled, linked with,&lt;BR /&gt;&lt;BR /&gt;  cc -DUSE_DLOPEN -g  -c +z libfoo.c&lt;BR /&gt;  ld -b -o libfoo.sl +I init_foo libfoo.o&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and output from a.out is:&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;- testlibfoo3: Version 0.14&lt;BR /&gt;- testlibfoo3: do dlopen for shared library libfoo.sl&lt;BR /&gt;-- libfoo: libfoo loaded&lt;BR /&gt;- testlibfoo3: using dlsym to get handle for libfoo&lt;BR /&gt;- testlibfoo3: call routine libfoo in libfoo.sl&lt;BR /&gt;-- libfoo: entered&lt;BR /&gt;-- libfoo: do dlopen for libfoo2.sl&lt;BR /&gt;-- libfoo: dlopen of libfoo2.sl failed - Can't open shared library: libfoo2.sl&lt;BR /&gt;Assertion failed: han != NULL, file libfoo.c, line 95&lt;BR /&gt;Abort (core dumped)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jan 2005 15:57:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452514#M848910</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2005-01-12T15:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452515#M848911</link>
      <description>&lt;BR /&gt;Ranganth,&lt;BR /&gt;&lt;BR /&gt;I did man dlopen and man dld_getenv.&lt;BR /&gt;I can see dlopen but not dld_getenv.&lt;BR /&gt;Where is documentation for "dld_genenv"?&lt;BR /&gt;I don't see a man entry for "dld_getenv".&lt;BR /&gt;I see an example of the use of dld_getenv &lt;BR /&gt;in dlopen(3C) and no specification. I see&lt;BR /&gt;information on it in shl_load. Someone here&lt;BR /&gt;claims they tried, unsuccessfully, to use&lt;BR /&gt;dld_getenv, but I don't have a reproducer&lt;BR /&gt;for it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Do I need MANPATH set or man pages installed?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Did you find any documentation on use &lt;BR /&gt;of shared libraries and $ORIGIN?&lt;BR /&gt;&lt;BR /&gt;Does $ORIGIN work only in conjunction with &lt;BR /&gt;-l or -l: ?&lt;BR /&gt;&lt;BR /&gt;Does libfoo.sl need an embedded pathname with $ORIGIN in it like a.out which chatr says looks like this:&lt;BR /&gt;&lt;BR /&gt;   shared executable&lt;BR /&gt;   shared library dynamic path search:&lt;BR /&gt;     SHLIB_PATH     enabled   first&lt;BR /&gt;     embedded path  enabled   second $ORIGIN:$ORIGIN/../mydirB&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;If so, how do I get put it there?&lt;BR /&gt;I do this now for libfoo.c:&lt;BR /&gt;&lt;BR /&gt;   &lt;BR /&gt;&lt;BR /&gt;More information:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The last time I tried to draw a diagaram of&lt;BR /&gt;the directory structure, the spaces got&lt;BR /&gt;eliminated so it looks like the post on &lt;BR /&gt;5-Jan. Another attempt.&lt;BR /&gt;&lt;BR /&gt;............. dlopen&lt;BR /&gt;............... |&lt;BR /&gt;...............ex12&lt;BR /&gt;................|&lt;BR /&gt;................/\&lt;BR /&gt;.............../..\&lt;BR /&gt;..........mydirA..mydirB&lt;BR /&gt;.............|.....|&lt;BR /&gt;............a.out libfoo.sl&lt;BR /&gt;..................libfoo2.sl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I ran a.out from various directories and&lt;BR /&gt;attempt to summarize the results I saw below. I get different results depending on the current working directory from which I run the a.out file. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Summary of current working directory,&lt;BR /&gt;command used, and result.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;current &lt;BR /&gt;working    &lt;BR /&gt;directory   command              result&lt;BR /&gt;---------  --------------------  ---------------&lt;BR /&gt;./dlopen   ./ex12/mydirA/a.out   crash as above&lt;BR /&gt;./ex12     ./mydirA/a.out        runs OK&lt;BR /&gt;./mydirA   ./a.out               crash as above&lt;BR /&gt;./mydirB   ../mydirA/a.out       runs OK&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You said in a prior post:&lt;BR /&gt;&lt;BR /&gt;"At load-time (run-time), the loader will substitute &lt;BR /&gt;$ORIGIN" with the full path of the directory where the &lt;BR /&gt;current load module (executable or shared library) was &lt;BR /&gt;loaded from."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The a.out is in a fixed place, and I don't understand &lt;BR /&gt;why I see diffent results depending on the current working &lt;BR /&gt;directory when I run the program.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Howard&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jan 2005 12:23:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452515#M848911</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2005-01-13T12:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452516#M848912</link>
      <description>howard,&lt;BR /&gt;&lt;BR /&gt;apparently something is wrong in the implementation of $ORIGIN on PA32. your program should have given you the 'OK' results in each of the 4 cases. i also noticed irregular behaviour with a similar program (where the dlopen is being done from with a shared library).&lt;BR /&gt;&lt;BR /&gt;the documentation currently available for $ORIGIN is sparse. i am in the linker/loader team, i will file a defect on the project to make sure the behaviour and documentation are fixed (you can also do this yourself through the response center).&lt;BR /&gt;&lt;BR /&gt;in the meanwhile: you can find documentation for dld_getenv in shl_load(3x) manpage.&lt;BR /&gt;&lt;BR /&gt;you can use any of the following workarounds:&lt;BR /&gt;&lt;BR /&gt;1. explicitly load shared libraries using dlopen as "$ORIGIN/../lib/libfoo.sl" and "$ORIGIN/libfoo2.sl" etc.&lt;BR /&gt;&lt;BR /&gt;2. build your application with +s linker option (passed through compiler as -Wl,+s) and set SHLIB_PATH=\$ORIGIN/../lib in a startup script.&lt;BR /&gt;&lt;BR /&gt;3. build the application with +s, and set SHLIB_PATH in the program itself :&lt;BR /&gt; putenv ("SHLIB_PATH=$ORIGIN/../lib");&lt;BR /&gt;and make the dld read it using&lt;BR /&gt; dld_getenv();</description>
      <pubDate>Mon, 17 Jan 2005 08:18:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452516#M848912</guid>
      <dc:creator>ranganath ramachandra</dc:creator>
      <dc:date>2005-01-17T08:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: shared libraries and $ORIGIN</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452517#M848913</link>
      <description>&lt;BR /&gt;&amp;gt;in the meanwhile: you can find documentation for dld_getenv in shl_load(3x) manpage.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;you can use any of the following workarounds:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;1. explicitly load shared libraries using dlopen as "$ORIGIN/../lib/libfoo.sl" and "$ORIGIN/libfoo2.sl" etc.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;2. build your application with +s linker option (passed through compiler as -Wl,+s) and set SHLIB_PATH=\$ORIGIN/../lib in a startup script.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;3. build the application with +s, and set SHLIB_PATH in the program itself :&lt;BR /&gt;putenv ("SHLIB_PATH=$ORIGIN/../lib");&lt;BR /&gt;and make the dld read it using&lt;BR /&gt;dld_getenv(); &lt;BR /&gt;&lt;BR /&gt;Ranganath,&lt;BR /&gt;&lt;BR /&gt;Thank you for your repsonse.&lt;BR /&gt;&lt;BR /&gt;1) RE: dlopen and $ORIGIN error -- part of program seems "as if" the loader is using the directory from which the program is run rather than the directory in which the program being run resides.&lt;BR /&gt;&lt;BR /&gt;2) Although I do not have a reproducer, a person here claims "dld_getenv" does not work correctly with "shl_load".&lt;BR /&gt;&lt;BR /&gt;3) We will look at your other suggestions.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Howard&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Jan 2005 10:44:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-libraries-and-origin/m-p/3452517#M848913</guid>
      <dc:creator>howard rutiezer_1</dc:creator>
      <dc:date>2005-01-17T10:44:41Z</dc:date>
    </item>
  </channel>
</rss>

