diff options
Diffstat (limited to 'devdocs/gnu_make/libraries_002fsearch.html')
| -rw-r--r-- | devdocs/gnu_make/libraries_002fsearch.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/devdocs/gnu_make/libraries_002fsearch.html b/devdocs/gnu_make/libraries_002fsearch.html new file mode 100644 index 00000000..e855a233 --- /dev/null +++ b/devdocs/gnu_make/libraries_002fsearch.html @@ -0,0 +1,9 @@ + <h1 class="subsection">Directory Search for Link Libraries</h1> <p>Directory search applies in a special way to libraries used with the linker. This special feature comes into play when you write a prerequisite whose name is of the form ‘<samp>-l<var>name</var></samp>’. (You can tell something strange is going on here because the prerequisite is normally the name of a file, and the <em>file name</em> of a library generally looks like <samp>lib<var>name</var>.a</samp>, not like ‘<samp>-l<var>name</var></samp>’.) </p> <p>When a prerequisite’s name has the form ‘<samp>-l<var>name</var></samp>’, <code>make</code> handles it specially by searching for the file <samp>lib<var>name</var>.so</samp>, and, if it is not found, for the file <samp>lib<var>name</var>.a</samp> in the current directory, in directories specified by matching <code>vpath</code> search paths and the <code>VPATH</code> search path, and then in the directories <samp>/lib</samp>, <samp>/usr/lib</samp>, and <samp><var>prefix</var>/lib</samp> (normally <samp>/usr/local/lib</samp>, but MS-DOS/MS-Windows versions of <code>make</code> behave as if <var>prefix</var> is defined to be the root of the DJGPP installation tree). </p> <p>For example, if there is a <samp>/usr/lib/libcurses.a</samp> library on your system (and no <samp>/usr/lib/libcurses.so</samp> file), then </p> <div class="example"> <pre class="example">foo : foo.c -lcurses + cc $^ -o $@ +</pre> +</div> <p>would cause the command ‘<samp>cc foo.c /usr/lib/libcurses.a -o foo</samp>’ to be executed when <samp>foo</samp> is older than <samp>foo.c</samp> or than <samp>/usr/lib/libcurses.a</samp>. </p> <p>Although the default set of files to be searched for is <samp>lib<var>name</var>.so</samp> and <samp>lib<var>name</var>.a</samp>, this is customizable via the <code>.LIBPATTERNS</code> variable. Each word in the value of this variable is a pattern string. When a prerequisite like ‘<samp>-l<var>name</var></samp>’ is seen, <code>make</code> will replace the percent in each pattern in the list with <var>name</var> and perform the above directory searches using each library file name. </p> <p>The default value for <code>.LIBPATTERNS</code> is ‘<samp>lib%.so lib%.a</samp>’, which provides the default behavior described above. </p> <p>You can turn off link library expansion completely by setting this variable to an empty value. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Free Software Foundation, Inc. <br>Licensed under the GNU Free Documentation License.<br> + <a href="https://www.gnu.org/software/make/manual/html_node/Libraries_002fSearch.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Libraries_002fSearch.html</a> + </p> +</div> |
