3
<title>Linking programs with the library - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Compiling-and-Linking.html#Compiling-and-Linking" title="Compiling and Linking">
9
<link rel="next" href="Linking-with-an-alternative-BLAS-library.html#Linking-with-an-alternative-BLAS-library" title="Linking with an alternative BLAS library">
10
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
14
Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.2 or
16
any later version published by the Free Software Foundation; with the
17
Invariant Sections being ``GNU General Public License'' and ``Free Software
18
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
19
and with the Back-Cover Text being (a) (see below). A copy of the
20
license is included in the section entitled ``GNU Free Documentation
23
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
24
GNU Manual, like GNU software.''-->
25
<meta http-equiv="Content-Style-Type" content="text/css">
26
<style type="text/css"><!--
27
pre.display { font-family:inherit }
28
pre.format { font-family:inherit }
29
pre.smalldisplay { font-family:inherit; font-size:smaller }
30
pre.smallformat { font-family:inherit; font-size:smaller }
31
pre.smallexample { font-size:smaller }
32
pre.smalllisp { font-size:smaller }
33
span.sc { font-variant:small-caps }
34
span.roman { font-family:serif; font-weight:normal; }
35
span.sansserif { font-family:sans-serif; font-weight:normal; }
41
<a name="Linking-programs-with-the-library"></a>
42
Next: <a rel="next" accesskey="n" href="Linking-with-an-alternative-BLAS-library.html#Linking-with-an-alternative-BLAS-library">Linking with an alternative BLAS library</a>,
43
Up: <a rel="up" accesskey="u" href="Compiling-and-Linking.html#Compiling-and-Linking">Compiling and Linking</a>
47
<h4 class="subsection">2.2.1 Linking programs with the library</h4>
49
<p><a name="index-compiling-programs_002c-library-paths-29"></a><a name="index-linking-with-GSL-libraries-30"></a><a name="index-libraries_002c-linking-with-31"></a>The library is installed as a single file, <samp><span class="file">libgsl.a</span></samp>. A shared
50
version of the library <samp><span class="file">libgsl.so</span></samp> is also installed on systems
51
that support shared libraries. The default location of these files is
52
<samp><span class="file">/usr/local/lib</span></samp>. If this directory is not on the standard search
53
path of your linker you will also need to provide its location as a
56
<p>To link against the library you need to specify
57
both the main library and a supporting <span class="sc">cblas</span> library, which
58
provides standard basic linear algebra subroutines. A suitable
59
<span class="sc">cblas</span> implementation is provided in the library
60
<samp><span class="file">libgslcblas.a</span></samp> if your system does not provide one. The following
61
example shows how to link an application with the library,
63
<pre class="example"> $ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
65
<p class="noindent">The default library path for <code>gcc</code> searches <samp><span class="file">/usr/local/lib</span></samp>
66
automatically so the <code>-L</code> option can be omitted when GSL is
67
installed in its default location.