Ошибка при связывании libxml2

У меня есть простой пример для libxml2, но он возвращает следующую ошибку:

$ gcc -Wall -lxml2 -I/usr/include/libxml2 -o ex1 ex1.c
/tmp/cc6OKSKJ.o: In function `main':
ex1.c:(.text+0x60): undefined reference to `xmlReadFile'
ex1.c:(.text+0x70): undefined reference to `xmlDocGetRootElement'
collect2: ld returned 1 exit status
$ xml2-config --libs
-lxml2
$ xml2-config --cflags
-I/usr/include/libxml2

Я использую Lubuntu 11.10 x86_64, и у меня есть все пакеты, которые мне нужны (ну, я думаю): libxml2, libxml2-dev, libxml2-dbg ... Вот код примера:

// gcc -Wall -lxml2 -I/usr/include/libxml2 -o ex1 ex1.c

#include <stdio.h>
#include <string.h>
#include <libxml/parser.h>

int main(int argc, char **argv)
{
    xmlDoc *document;
    xmlNode *root, *first_child, *node;
    char *filename;

    if (argc < 2)
    {
        fprintf(stderr, "Usage: %s filename.xml\n", argv[0]);
        return 1;
    }
    filename = argv[1];

    document = xmlReadFile(filename, NULL, 0);
    root = xmlDocGetRootElement(document);
    fprintf(stdout, "Root is <%s> (%i)\n", root->name, root->type);
    first_child = root->children;

    for (node = first_child; node; node = node->next)
    {
        fprintf(stdout, "\t Child is <%s> (%i)\n", node->name, node->type);
    }
    fprintf(stdout, "...\n");
    return 0;
}
5
задан Suugaku 19 October 2011 в 02:07
поделиться