15 * purpose. |
15 * purpose. |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 /** |
19 /** |
20 \page getting_started Getting Started |
20 \page hello_lemon Compile Your First Code |
21 |
|
22 \section hello_lemon Compile Your First Code |
|
23 |
21 |
24 If you have installed LEMON on your system you can paste the following |
22 If you have installed LEMON on your system you can paste the following |
25 code segment into a file called <tt>hello_lemon.cc</tt> to have a first |
23 code segment into a file called <tt>hello_lemon.cc</tt> to have a first |
26 working program that uses LEMON. |
24 working program that uses LEMON. |
27 |
25 |
28 \dontinclude hello_lemon.cc |
26 \dontinclude hello_lemon.cc |
29 \skip #include |
27 \skip #include |
30 \until } |
28 \until } |
31 |
29 |
32 First let us briefly explain how this example program works. |
30 First let us briefly explain how this example program works. |
33 (The used notions will be discussed in detail in the following chapter.) |
31 (The used notions will be discussed in detail in the following sections.) |
34 |
32 |
35 After some convenience typedefs we create a directed graph (\e digraph) |
33 After some convenience typedefs we create a directed graph (\e digraph) |
36 and add some nodes and arcs to it. |
34 and add some nodes and arcs to it. |
37 ListDigraph is one of the digraph classes implemented in LEMON. |
35 ListDigraph is one of the digraph classes implemented in LEMON. |
38 It is based on linked lists, therefore iterating through its nodes and |
36 It is based on linked lists, therefore iterating through its nodes and |
50 |
48 |
51 After that we create an arc map, which is actually a mapping that assigns |
49 After that we create an arc map, which is actually a mapping that assigns |
52 an \c int value (length) to each arc, and we set this value for each arc. |
50 an \c int value (length) to each arc, and we set this value for each arc. |
53 Finally we iterate through all arcs again and print their lengths. |
51 Finally we iterate through all arcs again and print their lengths. |
54 |
52 |
55 Now let's compile this simple example program. |
53 Now let us compile this simple example program. |
56 |
54 |
57 \subsection hello_lemon_system If LEMON is Installed System-Wide |
55 \section hello_lemon_system If LEMON is Installed System-Wide |
58 |
56 |
59 If your installation of LEMON into directory \c /usr/local was |
57 If LEMON is installed system-wide (into directory \c /usr/local), |
60 successful, then it is very easy to compile this program with the |
58 then it is very easy to compile this program with the |
61 following command (the argument <tt>-lemon</tt> tells the compiler |
59 following command (the argument <tt>-lemon</tt> tells the compiler |
62 that we are using the installed LEMON): |
60 that we are using the installed LEMON): |
63 |
61 |
64 \verbatim |
62 \verbatim |
65 g++ hello_lemon.cc -o hello_lemon -lemon |
63 g++ -lemon hello_lemon.cc -o hello_lemon |
66 \endverbatim |
64 \endverbatim |
67 |
65 |
68 As a result you will get the exacutable \c hello_lemon in the current |
66 As a result you will get the exacutable \c hello_lemon in the current |
69 directory, which you can run by the following command. |
67 directory, which you can run by the following command. |
70 |
68 |
71 \verbatim |
69 \verbatim |
72 ./hello_lemon |
70 ./hello_lemon |
73 \endverbatim |
71 \endverbatim |
74 |
72 |
75 \subsection hello_lemon_user If LEMON is Installed User-Local |
73 \section hello_lemon_user If LEMON is Installed User-Local |
76 |
74 |
77 Compiling the code is a bit more difficult if you installed LEMON |
75 Compiling the code is a bit more difficult if you installed LEMON |
78 user-local into a directory (e.g. <tt>~/lemon</tt>) or if you just |
76 user-local into a directory (e.g. <tt>~/lemon</tt>) or if you just |
79 skipped the step <tt>make install</tt>. |
77 skipped the step <tt>make install</tt>. |
80 You have to issue a command like this. |
78 You have to issue a command like this. |
81 |
79 |
82 \verbatim |
80 \verbatim |
83 g++ -I ~/lemon hello_lemon.cc -o hello_lemon -lemon -L ~/lemon/lemon/.libs |
81 g++ -lemon -I ~/lemon -L ~/lemon/lemon/.libs hello_lemon.cc -o hello_lemon |
84 \endverbatim |
82 \endverbatim |
85 |
|
86 \subsubsection hello_lemon_pkg_config Use pkg-config |
|
87 |
|
88 \todo Write this sub-subsection (\ref hello_lemon_pkg_config). |
|
89 |
83 |
90 If everything has gone well, then our program prints out the followings. |
84 If everything has gone well, then our program prints out the followings. |
91 |
85 |
92 \verbatim |
86 \verbatim |
93 Hello World! |
87 Hello World! |