<?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 Linking shared libraries in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852164#M98119</link>
    <description>&lt;!--!*#--&gt;I have been trying to link a shared library to my program. There are no errors given by any of the commands but while executing the program i get an error. Below are the steps i followed and the results&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; ls&lt;BR /&gt;main.c                 test.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -c -fPIC test.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -shared -o libtest.so test.o&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -c main.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; set LD_LIBRARY_PATH=(${LD_LIBRARY_PATH}:/h/preetam/junkc)&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; echo $LD_LIBRARY_PATH&lt;BR /&gt;/usr/lib:/usr/local/lib:/h/preetmo/junkc&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -o mainprog main.o -L. -ltest&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; mainprog&lt;BR /&gt;ld.so.1: mainprog: fatal: libtest.so: open failed: No such file or directory&lt;BR /&gt;Killed&lt;BR /&gt;&lt;BR /&gt;Please let me know what is wrong with it??</description>
    <pubDate>Tue, 29 Aug 2006 05:20:36 GMT</pubDate>
    <dc:creator>Preetam</dc:creator>
    <dc:date>2006-08-29T05:20:36Z</dc:date>
    <item>
      <title>Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852164#M98119</link>
      <description>&lt;!--!*#--&gt;I have been trying to link a shared library to my program. There are no errors given by any of the commands but while executing the program i get an error. Below are the steps i followed and the results&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; ls&lt;BR /&gt;main.c                 test.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -c -fPIC test.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -shared -o libtest.so test.o&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -c main.c&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; set LD_LIBRARY_PATH=(${LD_LIBRARY_PATH}:/h/preetam/junkc)&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; echo $LD_LIBRARY_PATH&lt;BR /&gt;/usr/lib:/usr/local/lib:/h/preetmo/junkc&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -o mainprog main.o -L. -ltest&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; mainprog&lt;BR /&gt;ld.so.1: mainprog: fatal: libtest.so: open failed: No such file or directory&lt;BR /&gt;Killed&lt;BR /&gt;&lt;BR /&gt;Please let me know what is wrong with it??</description>
      <pubDate>Tue, 29 Aug 2006 05:20:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852164#M98119</guid>
      <dc:creator>Preetam</dc:creator>
      <dc:date>2006-08-29T05:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852165#M98120</link>
      <description>Duplicate of:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1055339" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1055339&lt;/A&gt;</description>
      <pubDate>Tue, 29 Aug 2006 06:16:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852165#M98120</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-08-29T06:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852166#M98121</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;can you check with 'ldd mainprog' and 'chatr mainprog' where the program expects the shared libraries?&lt;BR /&gt;&lt;BR /&gt;Then create a link or add the directory to your env PATH.&lt;BR /&gt;Maybe you have to set your LD_LIBRARY_PATH in the program?&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Volkmar&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Aug 2006 06:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852166#M98121</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2006-08-29T06:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852167#M98122</link>
      <description>Hi Volkmar,&lt;BR /&gt;I used ldd mainprog and below is the output&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; ldd mainprog&lt;BR /&gt;        libtest.so =&amp;gt;    (file not found)&lt;BR /&gt;        libc.so.1 =&amp;gt;     /usr/lib/libc.so.1&lt;BR /&gt;        libdl.so.1 =&amp;gt;    /usr/lib/libdl.so.1&lt;BR /&gt;        /usr/platform/SUNW,Ultra-4/lib/libc_psr.so.1&lt;BR /&gt;&lt;BR /&gt;For chatr command was not found.&lt;BR /&gt;&lt;BR /&gt;I have updated the LD_LIBRARY_PATH as mentioned in the previous post to my current directory but it still doesnt work. I have also tried giving the path to gcc in the command line as follows:&lt;BR /&gt;&lt;BR /&gt;[preetam@cyclone]junkc&amp;gt; gcc -o mainprog shared.o -L. -ltest -Wl,-rpath,/h/preetam/libtest&lt;BR /&gt;&lt;BR /&gt;but it still doesnt work. &lt;BR /&gt;&lt;BR /&gt;I read somewhere that there is an alternative method to regenerate the library cache file by typing "ldconfig" in the installed directory. But my system does not have even that command!!! :(&lt;BR /&gt;&lt;BR /&gt;I am using SunOS 5.8&lt;BR /&gt;&lt;BR /&gt;Preetam.</description>
      <pubDate>Tue, 29 Aug 2006 22:51:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852167#M98122</guid>
      <dc:creator>Preetam</dc:creator>
      <dc:date>2006-08-29T22:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852168#M98123</link>
      <description>Use:&lt;BR /&gt;&lt;BR /&gt;gcc -o mainprog main.o -L. -L/h/preetmo/junkc -ltest&lt;BR /&gt;&lt;BR /&gt;As far as i remember&lt;BR /&gt;&lt;BR /&gt;LD_LIBRARY_PATH is not used during searching of libraries.&lt;BR /&gt;Its used during run-time.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Aug 2006 00:42:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852168#M98123</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2006-08-30T00:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852169#M98124</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;I don't know how to use 'gcc', but maybe you have to give the complete path of 'libtest.so' when you declare it as a library.&lt;BR /&gt;Where have you stored it, in your home dir?&lt;BR /&gt;&lt;BR /&gt;Maybe you also can create a link in /usr/lib to 'libtest.so', also I think it's not the 'clean' way to do it.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Volkmar&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Aug 2006 02:35:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852169#M98124</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2006-08-30T02:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852170#M98125</link>
      <description>Hi vibhor,&lt;BR /&gt;I tried what you said. Same result!! does not work...&lt;BR /&gt;&lt;BR /&gt;Volkmar I cant create a link in /usr/lib as it is on a different file system. I used command ln -f ~/junkc/libtest.so&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Preetam.</description>
      <pubDate>Wed, 30 Aug 2006 05:42:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852170#M98125</guid>
      <dc:creator>Preetam</dc:creator>
      <dc:date>2006-08-30T05:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852171#M98126</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;for a short test - copy libtest.so into /usr/lib and see if it works.&lt;BR /&gt;&lt;BR /&gt;V.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Aug 2006 05:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852171#M98126</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2006-08-30T05:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852172#M98127</link>
      <description>It seems your problems are on a Sun system since you mentioned "SunOS 5.8".  Why are you asking these questions here??&lt;BR /&gt;&lt;BR /&gt;On HP-UX, if you have exported the PWD in LD_LIBRARY_PATH it should just work.  Not knowing if you are using a "real" shell or not, I don't think "set" exports the variable??  The scummy C shell requires setenv.  A "real" shell requires export.</description>
      <pubDate>Wed, 30 Aug 2006 05:58:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852172#M98127</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-08-30T05:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852173#M98128</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;I think his 'set' worked, because in his 'echo' you can see the added path.&lt;BR /&gt;&lt;BR /&gt;V.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Aug 2006 06:03:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852173#M98128</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2006-08-30T06:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Linking shared libraries</title>
      <link>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852174#M98129</link>
      <description>&amp;gt;V. Nyga: I think his 'set' worked, because in his 'echo'&lt;BR /&gt;&lt;BR /&gt;I first thought so too but that is not how shell variables work.  You should use the env(1) command and see if the variable is exported.  Using any command with a $variable will just have the shell expand it without exporting it.&lt;BR /&gt;$ csh  # start scummy C shell&lt;BR /&gt;% set xxx=yyy&lt;BR /&gt;% echo $xxx  # this command proves nothing&lt;BR /&gt;yyy&lt;BR /&gt;% env | fgrep xxx&lt;BR /&gt;% setenv xxx "$xxx"&lt;BR /&gt;% env | fgrep xxx  # now part of the environment&lt;BR /&gt;xxx=yyy</description>
      <pubDate>Wed, 30 Aug 2006 06:25:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/linking-shared-libraries/m-p/3852174#M98129</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-08-30T06:25:26Z</dc:date>
    </item>
  </channel>
</rss>

