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="gl">
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"/>
9
<desc>Engadir unha biblioteca personalizada a un obxectivo.</desc>
10
<credit type="author">
11
<name>Sébastien Granjoux</name>
12
<email>seb.sfo@free.fr</email>
14
<credit type="editor">
15
<name>Philip Chimento</name>
16
<email>philip.chimento@gmail.com</email>
20
<title>Engadir unha biblioteca personalizada</title>
22
<p>It is easier to use a packaged library, which is common on Linux, so
23
check if it is the case <link xref="project-manager-module-new">here</link>.
24
But else you can still use the library as explained below.</p>
26
<p>In order to use a library in C, you need to tell the compiler
27
where the header files are, and tell the linker where to find the
28
needed libraries. The issue is that your program will not compile
29
on another computer if the header and the libraries are elsewhere.</p>
33
<p>Select the directory containing the program where you want to
34
add the library in the <gui>project view</gui>, click on the
35
right mouse button to make the <gui>project context menu</gui>
36
appear and select <gui>Properties</gui>.</p>
38
<p>Or from the <gui>main menu</gui>, select <guiseq><gui>Project</gui>
39
<gui>Properties</gui></guiseq>. By default, it edits the
40
properties of the currently selected item in the project view.
41
You can select a different item in the drop-down list button.</p>
44
<p>If the header files are installed in a standard location
45
(<file>/usr/include</file>) you don't have to set this. If not,
46
you need to add <input>-I<var>include_path</var></input> in
47
the <gui>C preprocessor flags</gui> property if you are using
48
<app>gcc</app> as your compiler. You can add several paths separated with
49
spaces. These options will be used for all targets inside this
52
<p>You might have to expand the <gui>More options</gui> button to see this.
53
Click on the <gui>Apply</gui> button when you are done.</p>
56
<p>Next, you need to add the library to a target.
57
Select the target where you want to
58
add the library in the <gui>project view</gui>, click on the
59
right mouse button to make the <gui>project context menu</gui>
60
appear and select <gui>Properties</gui>.</p>
62
<p>Or from the <gui>main menu</gui>, select <guiseq><gui>Project</gui>
63
<gui>Properties</gui></guiseq>. By default, it edits the
64
properties of the currently selected item in the project view.
65
You can select a different item in the drop-down list button.</p>
68
<p>You need to set the <gui>Linker flags</gui> property, adding
69
<input>-l<var>library_name</var></input> if your compiler is <app>gcc</app>.
70
<var>library_name</var> is the name of the library file without the
71
<file>lib</file> prefix and without the <file>.a</file> or
72
<file>.so</file> extension.</p>
74
<p>If the library is in not in a standard directory, <app>gcc</app>
75
can look in additional directories with the option
76
<input>-L<var>library_path</var></input>.</p>