Using Anjuta

With Anjuta adding a library supporting pkg-config can be almost done without the keyboard.

4.2.1. With pkg-config

  1. Open the file main.c of the Anjuta project created in the previous chapter. Replace it with the following text:

    Example 4-2main.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;
    	}
    }
  2. Select Project ▸ Properties ▸ Packages, to get the package properties dialog.

  3. Click on Add module button and Enter a name in the Module/Package column, "XML" by example.

  4. Click on Add Package 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 pkg-config. Select libxml-2.0. Then click on Add button.

  5. The package properties dialog should look like the following:

    Figure 4-1Project package properties dialog

    The 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.

  6. Close the dialog and select Project ▸ Refresh. This should not be needed but is necessary with the current version of Anjuta. This bug has already been reported (#541694) and will be fixed soon

  7. 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.

  8. 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-2Target properties dialog
  9. Click on Close and that's all. You can select Build ▸ Build to rebuild your project.

4.2.2. Without pkg-config

Anjuta has no real support for library not using pkg-config. You need to edit the configure.ac directly to add all necessary macros. For passing flags to each target you can select the Advanced button in the target properties dialog.