Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

On Big Red or Quarry, how do I link to a library?

On Unix systems (including Big Red and Quarry at Indiana University), if the library file resides in one of the standard directories (i.e., /usr/lib/lib or /usr/local/lib), you can link to the library by using the  -l  flag (lowercase L). For example, linking with the -lx flag actually means the library file is libx.a or libx.so in one of the standard directories.

If the library is not in a standard directory, use the  -L  flag (uppercase L) to explicitly specify the library file search path. For example, if the LAPACK library resides 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 man page. Also, see When compiling a C program in Unix, why do I get "ld: Unresolved:"?

Note: In some special cases, you cannot link to a library using  -l  flags; for example, on Solaris systems, the Sun Performance Library uses -xlic_lib .

For more information, refer to Frequently Asked Questions maintained by IU's High Performance Applications staff.

This document was developed with support from the National Science Foundation (NSF) under Grant No. 0503697 to the University of Chicago and subcontracted to Indiana University. Additional support was provided by IU through its participation in the TeraGrid, which is supported by the NSF under Grants No. 0833618, SCI451237, SCI535258, and SCI504075. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.

This is document akqm in domains all and tgrid-all.
Last modified on July 15, 2009.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.