Installing software in your home directory: Difference between revisions

Jump to navigation Jump to search
Marked this version for translation
No edit summary
(Marked this version for translation)
Line 29: Line 29:
{{Command|module load library_name/x.y.z}}
{{Command|module load library_name/x.y.z}}


<!--T:17-->
With the module loaded, you can now modify the link phase of your build process to include the library, for example
With the module loaded, you can now modify the link phase of your build process to include the library, for example
{{Command|gcc -o my_prog file1.o file2.o -llapack -lblas}}
{{Command|gcc -o my_prog file1.o file2.o -llapack -lblas}}
if I wanted to link with the LAPACK and BLAS libraries.
if I wanted to link with the LAPACK and BLAS libraries.


<!--T:18-->
The link line needs to contain <tt>-l</tt> prefixed to the library name, which will be a file that has the extension <tt>.a</tt> or <tt>.so</tt>. The documentation for the library will typically inform you of the name of this file and, if there are more than one such file (as may be the case), the order in which they should be linked.
The link line needs to contain <tt>-l</tt> prefixed to the library name, which will be a file that has the extension <tt>.a</tt> or <tt>.so</tt>. The documentation for the library will typically inform you of the name of this file and, if there are more than one such file (as may be the case), the order in which they should be linked.


<!--T:19-->
You will also need to load the library module when you wish to run this software, not only during the building of it.
You will also need to load the library module when you wish to run this software, not only during the building of it.


<!--T:20-->
Note that a library [[Using modules | modulefile]] will set environment variables <tt>CPATH</tt> and <tt>LIBRARY_PATH</tt> pointing to the location of the library itself and its include files. These environment variables are supported by most compilers (for example, [https://software.intel.com/en-us/node/522775 Intel] and [https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html GCC]), which will automatically try the directories listed in those environment variables during compilation and linking phases. This feature allows you you to easily link against the library without specifying its location explicitly by passing the <tt>-I</tt> and <tt>-L</tt> options to the compiler. If your make- or a config- file calls for an explicit location of the library to pass it to the compiler via those flags, you can safely skip setting those parameters altogether (usually by leaving the location of the library blank in a config file).
Note that a library [[Using modules | modulefile]] will set environment variables <tt>CPATH</tt> and <tt>LIBRARY_PATH</tt> pointing to the location of the library itself and its include files. These environment variables are supported by most compilers (for example, [https://software.intel.com/en-us/node/522775 Intel] and [https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html GCC]), which will automatically try the directories listed in those environment variables during compilation and linking phases. This feature allows you you to easily link against the library without specifying its location explicitly by passing the <tt>-I</tt> and <tt>-L</tt> options to the compiler. If your make- or a config- file calls for an explicit location of the library to pass it to the compiler via those flags, you can safely skip setting those parameters altogether (usually by leaving the location of the library blank in a config file).


Bureaucrats, cc_docs_admin, cc_staff
2,773

edits

Navigation menu