1
<?xml version="1.0" encoding="utf-8"?>
2
<page xmlns="http://projectmallard.org/1.0/" type="topic" style="task" id="project-manager-library-add" xml:lang="sl">
4
<info xmlns:facet="http://projectmallard.org/facet/1.0/">
5
<facet:tag key="all-pages" value="whatever"/> <!--Include page in index-->
6
<link type="guide" xref="project-manager-library" group="sixth"/>
7
<link type="seealso" xref="project-manager-target"/>
8
<revision pkgversion="3.0" version="0.1" date="2011-03-27" status="incomplete"/>
10
Add a custom library to a target.
12
<credit type="author">
13
<name>Sébastien Granjoux</name>
14
<email>seb.sfo@free.fr</email>
16
<credit type="editor">
17
<name>Philip Chimento</name>
18
<email>philip.chimento@gmail.com</email>
22
<title>Add a Custom Library</title>
24
<p>It is easier to use a packaged library, which is common on Linux, so
25
check if it is the case <link xref="project-manager-module-new">here</link>.
26
But else you can still use the library as explained below.</p>
28
<p>In order to use a library in C, you need to tell the compiler
29
where the header files are, and tell the linker where to find the
30
needed libraries. The issue is that your program will not compile
31
on another computer if the header and the libraries are elsewhere.</p>
35
<p>Select the directory containing the program where you want to
36
add the library in the <gui>project view</gui>, click on the
37
right mouse button to make the <gui>project context menu</gui>
38
appear and select <gui>Properties</gui>.</p>
40
<p>Or from the <gui>main menu</gui>, select <guiseq><gui>Project</gui>
41
<gui>Properties</gui></guiseq>. By default, it edits the
42
properties of the currently selected item in the project view.
43
You can select a different item in the drop-down list button.</p>
46
<p>If the header files are installed in a standard location
47
(<file>/usr/include</file>) you don't have to set this. If not,
48
you need to add <input>-I<var>include_path</var></input> in
49
the <gui>C preprocessor flags</gui> property if you are using
50
<app>gcc</app> as your compiler. You can add several paths separated with
51
spaces. These options will be used for all targets inside this
54
<p>You might have to expand the <gui>More options</gui> button to see this.
55
Click on the <gui>Apply</gui> button when you are done.</p>
58
<p>Next, you need to add the library to a target.
59
Select the target where you want to
60
add the library in the <gui>project view</gui>, click on the
61
right mouse button to make the <gui>project context menu</gui>
62
appear and select <gui>Properties</gui>.</p>
64
<p>Or from the <gui>main menu</gui>, select <guiseq><gui>Project</gui>
65
<gui>Properties</gui></guiseq>. By default, it edits the
66
properties of the currently selected item in the project view.
67
You can select a different item in the drop-down list button.</p>
70
<p>You need to set the <gui>Linker flags</gui> property, adding
71
<input>-l<var>library_name</var></input> if your compiler is <app>gcc</app>.
72
<var>library_name</var> is the name of the library file without the
73
<file>lib</file> prefix and without the <file>.a</file> or
74
<file>.so</file> extension.</p>
76
<p>If the library is in not in a standard directory, <app>gcc</app>
77
can look in additional directories with the option
78
<input>-L<var>library_path</var></input>.</p>