On the research computing systems at IU, how do I link to a library?

In most Linux-based or Unix-like operating systems, such those running on the research computing systems at Indiana University, you can link to a library file located in a standard directory (e.g., /usr/lib/lib or /usr/local/lib) by using the -l (lowercase L) flag. For example, using the -lx flag will link to the libx.so or libx.a library file stored in one of the standard directories.

If a library file is not located in a standard directory, use the -L (uppercase L) flag to specify the path to the file. For example, if the LAPACK library is in the /libapps/lapack directory, use the following to link with it:

  -L/libapps/lapack -llapack

The linker ld usually searches in the directories specified by the -L flag first, and then in the standard directories. The first match will satisfy the search. If files with both .a and .so extensions are found in a directory, the .so file is used.

For more, see the ld manual page.

This is document akqm in the Knowledge Base.
Last modified on 2018-01-18 11:03:47.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.