Enabling The Multiverse Repository On Ubuntu

If you need to install the Sun JDK or some other non-free software on Ubuntu, you’ll likely need to enable the multiverse repository. To do this from the command line, you’ll need to modify the file /etc/apt/sources.list.

The file /etc/apt/sources.list looks like this:

deb http://archive.ubuntu.com/ubuntu/ karmic main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ karmic main restricted universe
 
deb http://archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe
 
deb http://security.ubuntu.com/ubuntu karmic-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted universe

To enable the multiverse repository, add the word multiverse after each occurrence of the word universe. The file should then look like this:

deb http://archive.ubuntu.com/ubuntu/ karmic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ karmic main restricted universe multiverse
 
deb http://archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe multiverse
 
deb http://security.ubuntu.com/ubuntu karmic-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted universe multiverse

After running the command apt-get update, you should be able to install packages within the multiverse repository.

Posted in Uncategorized | Leave a comment

Determining What A Program Is Linked To

To determine what shared objects a program is linked to, use the ldd command. For example, running this command:

ldd /usr/bin/curl

gives the following output on my Ubuntu 9.10 box:

	linux-vdso.so.1 =>  (0x00007fffb6b78000)
	libcurl.so.4 => /usr/lib/libcurl.so.4 (0x00007f9226904000)
	libz.so.1 => /lib/libz.so.1 (0x00007f92266ed000)
	libc.so.6 => /lib/libc.so.6 (0x00007f922637e000)
	librt.so.1 => /lib/librt.so.1 (0x00007f9226176000)
	libidn.so.11 => /usr/lib/libidn.so.11 (0x00007f9225f43000)
	liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0x00007f9225d35000)
	libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0x00007f9225aec000)
	libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f92258be000)
	libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f9225670000)
	libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f92252e9000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f9226b4b000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00007f92250cd000)
	libresolv.so.2 => /lib/libresolv.so.2 (0x00007f9224eb4000)
	libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x00007f9224c9a000)
	libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0x00007f92249f8000)
	libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f9224740000)
	libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f9224515000)
	libcom_err.so.2 => /lib/libcom_err.so.2 (0x00007f9224311000)
	libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f9224109000)
	libdl.so.2 => /lib/libdl.so.2 (0x00007f9223f05000)
	libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00007f9223d02000)
	libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0x00007f9223af1000)
	libgcrypt.so.11 => /lib/libgcrypt.so.11 (0x00007f9223879000)
	libgpg-error.so.0 => /lib/libgpg-error.so.0 (0x00007f9223675000)

The items left of the arrows are the libraries expected by the program. The items right of the arrows are the absolute paths of the libraries found by searching the directories listed in the LD_LIBRARY_PATH variable and the directories listed in /etc/ld.so.conf.

Posted in Linux | Tagged | Leave a comment

Using LD_LIBRARY_PATH

When testing an application, it’s often useful to install it outside of the standard directories /usr and /usr/local.  This technique makes it easy to delete the application should you want to get rid of it, since its files won’t be strewn about other files you’d like to keep.

If the application only uses shared objects stored in /usr/lib and /usr/local/lib (or other directories listed in /etc/ld.so.conf), then running it is usually as simple as invoking it from a command line.  However, if it uses shared objects outside those listed in /etc/ld.so.conf, when running it you’ll see errors such as this one:

./myapp: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory

The solution is to set the environment variable LD_LIBRARY_PATH before executing the application. For example, if libmylib.so is contained in the directory /path/to/lib, then setting LD_LIBRARY_PATH as follows

export LD_LIBRARY_PATH=/path/to/lib:$LD_LIBRARY_PATH

enables myapp to find libmylib.so when executed.

For more information about the LD_LIBRARY_PATH environment variable and shared objects, see yolinux.com’s tutorial.

Posted in Linux | Tagged , | Leave a comment