Using Anjuta
With Anjuta adding a library supporting pkg-config can be almost done without the keyboard.
- 4.2.1. With pkg-config
- 4.2.2. Without pkg-config
4.2.1. With pkg-config
-
Open the file main.c of the Anjuta project created in the previous chapter. Replace it with the following text:
Example 4-2 main.c using libxml2:#include <libxml/parser.h> #include <stdio.h> int main() { xmlDocPtr doc; doc = xmlParseFile ("testfile.xml"); if (doc == NULL) { printf ("Document not parsed successfully. \n"); return -1; } else { printf ("Document parsed successfully.\n"); xmlFreeDoc(doc); return 0; } }
-
Select
, to get the package properties dialog. -
Click on Module/Package column, "XML" by example.
button and Enter a name in the -
Click on pkg-config. Select libxml-2.0. Then click on button.
button that should be enabled now. You get the a dialog where you can select the library that you want to use. This dialog list all libraries supporting -
The package properties dialog should look like the following:
Figure 4-1 Project package properties dialogThe module XML contains one library named libxml-2.0. You can define a minimum version required by clicking in the version column and writing >= 2.4. All this operation add the necessary lines in the file configure.ac.
-
Close the dialog and select Anjuta. This bug has already been reported (#541694) and will be fixed soon
. This should not be needed but is necessary with the current version of -
In the project view, select the project target tutprog and click on right button to get a context menu and select Properties. You will get the target properties dialog.
-
This dialog will list all modules available in your project, just check the XML module. This will modify the file Makefile.am to use the right library.
Figure 4-2 Target properties dialog -
Click on
and that's all. You can select to rebuild your project.