<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WiredRevolution.com &#187; LD_LIBRARY_PATH</title>
	<atom:link href="http://www.wiredrevolution.com/tag/ld_library_path/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiredrevolution.com</link>
	<description>A Bit of Linux Wisdom</description>
	<lastBuildDate>Wed, 18 Jan 2012 22:45:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>How to correctly use LD_LIBRARY_PATH</title>
		<link>http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-correctly-use-ld_library_path</link>
		<comments>http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path#comments</comments>
		<pubDate>Wed, 22 Oct 2008 12:32:13 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[bashrc]]></category>
		<category><![CDATA[dynamic library]]></category>
		<category><![CDATA[ELF]]></category>
		<category><![CDATA[environment variable]]></category>
		<category><![CDATA[ldd]]></category>
		<category><![CDATA[LD_LIBRARY_PATH]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=453</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/sysadmin_icon.png" width="80" height="94" alt="" title="system administration" /><br/>The LD_LIBRARY_PATH environment variable contains a colon separated list of paths that the linker uses to resolve library dependencies of ELF executables at run-time. These paths will be given priority over the standard library paths /lib and /usr/lib. The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH has [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd' rel='bookmark' title='Permanent Link: View dynamic library dependencies with ldd'>View dynamic library dependencies with ldd</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/select-threading-implementation-using-ld_assume_kernel' rel='bookmark' title='Permanent Link: Select threading implementation using LD_ASSUME_KERNEL'>Select threading implementation using LD_ASSUME_KERNEL</a></li>
<li><a href='http://www.wiredrevolution.com/guides/how-to-get-boxee-to-correctly-identify-local-media-files' rel='bookmark' title='Permanent Link: How to get Boxee to correctly identify local media files'>How to get Boxee to correctly identify local media files</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/sysadmin_icon.png" width="80" height="94" alt="" title="system administration" /><br/><p>The LD_LIBRARY_PATH environment variable contains a colon separated list of paths that the linker uses to resolve library dependencies of ELF executables at run-time. These paths will be given priority over the standard library paths <strong>/lib</strong> and <strong>/usr/lib</strong>.  The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH has been exhausted.</p>
<p>The best way to use LD_LIBRARY_PATH is to set it on the command line or script immediately before executing the program. This way you can keep the new LD_LIBRARY_PATH isolated from the rest of your system.</p>
<pre>
$ export LD_LIBRARY_PATH="/list/of/library/paths:/another/path"
$ ./program
</pre>
<p>In general it is not a good practice to have LD_LIBRARY_PATH permanently set in your environment. This could lead to unintended side effects as programs can link to unintended libraries producing strange results or unexpectedly crashing. There is also the possibility introducing potential security threats. </p>
<p>All those warnings aside, if you are using BASH you can set it permanently by placing a line similar to this in your <strong>.bashrc</strong> in your home directory.</p>
<pre>
export LIBRARY_PATH="/list/of/library/paths:/another/path"
</pre>
<p>A common case for setting LD_LIBRARY_PATH is when you have an application that requires dynamic libraries which were not installed in the standard library locations.</p>
<p>You can check if the linker can locate all the required libraries by <a href="http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd">running the ldd command</a>.</p>
<pre>
$ ldd ~/myprogram
</pre>
<pre>
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libmylib.so.1 => not found
</pre>
<p>The linker cannot find libmylib.so.1. </p>
<p>Let&#8217;s assume this library exists here &#8220;~/myprogdir/lib/libmylib.so.1&#8243;. We have to set LD_LIBRARY_PATH to include this path for the application to successfully run.</p>
<pre>
$ export LD_LIBRARY_PATH="~/myprogdir/lib/:$LD_LIBRARY_PATH"
$ ldd ~/myprogram
</pre>
<pre>
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libmylib.so.1 => ~/myprogdir/lib/libmylib.so.1 (0x00002b4eca9fa000)
</pre>
<p>The linker has now found all the required libraries.</p>


<p>Related posts<ol><li><a href='http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd' rel='bookmark' title='Permanent Link: View dynamic library dependencies with ldd'>View dynamic library dependencies with ldd</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/select-threading-implementation-using-ld_assume_kernel' rel='bookmark' title='Permanent Link: Select threading implementation using LD_ASSUME_KERNEL'>Select threading implementation using LD_ASSUME_KERNEL</a></li>
<li><a href='http://www.wiredrevolution.com/guides/how-to-get-boxee-to-correctly-identify-local-media-files' rel='bookmark' title='Permanent Link: How to get Boxee to correctly identify local media files'>How to get Boxee to correctly identify local media files</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>View dynamic library dependencies with ldd</title>
		<link>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=view-dynamic-library-dependencies-with-ldd</link>
		<comments>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd#comments</comments>
		<pubDate>Fri, 17 Oct 2008 12:49:15 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[dl_open]]></category>
		<category><![CDATA[dynamic library]]></category>
		<category><![CDATA[ELF]]></category>
		<category><![CDATA[ld.so]]></category>
		<category><![CDATA[ldd]]></category>
		<category><![CDATA[LD_LIBRARY_PATH]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=377</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/>The ldd command allows you to view detailed information about library dependencies of dynamically linked programs and other shared libraries. ldd uses the runtime linker ld.so which reads the ELF formatted executable to generate the output. It is a helpful tool to have at your disposal when debugging broken programs. Here ldd examines the &#8216;ls&#8217; [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path' rel='bookmark' title='Permanent Link: How to correctly use LD_LIBRARY_PATH'>How to correctly use LD_LIBRARY_PATH</a></li>
<li><a href='http://www.wiredrevolution.com/commands/list-all-open-files-with-lsof' rel='bookmark' title='Permanent Link: List all open files with lsof'>List all open files with lsof</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/view-process-environment-details-with-proc' rel='bookmark' title='Permanent Link: View process environment details with proc'>View process environment details with proc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/commands_icon.png" width="80" height="69" alt="" title="commands" /><br/><p>The ldd command allows you to view detailed information about library dependencies of dynamically linked programs and other shared libraries. ldd uses the runtime linker <strong>ld.so</strong> which reads the <strong>ELF</strong> formatted executable to generate the output. It is a helpful tool to have at your disposal when debugging broken programs.</p>
<p>Here ldd examines the &#8216;ls&#8217; executable. The output displays the dependencies as well as how they will be resolved if run with the current environment.</p>
<pre>
$ ldd /bin/ls
</pre>
<pre>
	linux-vdso.so.1 =>  (0x00007fffe0dfe000)
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libacl.so.1 => /lib/libacl.so.1 (0x00002b4eca297000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libattr.so.1 => /lib/libattr.so.1 (0x00002b4eca9fa000)
</pre>
<p>Sometimes you will see that an application can&#8217;t resolve one or more libraries. It would most likely fail to execute at this moment if you see a &#8220;not found&#8221; entry like this.</p>
<pre>
$ ldd ~/myprogram
</pre>
<pre>
	librt.so.1 => /lib/librt.so.1 (0x00002b4eca08e000)
	libc.so.6 => /lib/libc.so.6 (0x00002b4eca49f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00002b4eca7df000)
	/lib64/ld-linux-x86-64.so.2 (0x00002b4ec9e72000)
	libmylib.so.1 => not found
</pre>
<p>To resolve these type of issues you can either install the missing libraries, or if they are already installed, update the <a href="http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path">LD_LIBRARY_PATH environment variable</a> with the path to the libraries.</p>
<p>Once you have done one of these two things, rerun ldd on the executable and verify that the library dependency can now be correctly resolved.</p>
<p>One last caveat, ldd will not display information about shared libraries that the program may try to open using the <strong>glibc</strong> function <strong>dl_open</strong>() during its execution.</p>


<p>Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path' rel='bookmark' title='Permanent Link: How to correctly use LD_LIBRARY_PATH'>How to correctly use LD_LIBRARY_PATH</a></li>
<li><a href='http://www.wiredrevolution.com/commands/list-all-open-files-with-lsof' rel='bookmark' title='Permanent Link: List all open files with lsof'>List all open files with lsof</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/view-process-environment-details-with-proc' rel='bookmark' title='Permanent Link: View process environment details with proc'>View process environment details with proc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/commands/view-dynamic-library-dependencies-with-ldd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

