I am trying to use libxml2 to create a library file, I am on Ubuntu so libxml2 is preinstalled. I am trying to use xmlwriter.h to create the file, if I use the example testwriter program I can successfully compile it, but for some reason my program will not compile. I just can't figure out what I'm doing wrong, it acts like the functions from xmlwriter.h are not defined, but I successfully included the header file. Also, this only happens with xmlwriter.h, I can use the other header files from libxml2 and they work fine, but everything from xmlwriter.h act like they are not defined.
Here is the function in my program:
Code:
#include <libxml/xmlwriter.h>
#include "library.h"
#include "globalvars.h"
void load_library() {
xmlDocPtr doc;
if(stat("library.xml", &STAT) < 0) {
// Create library
xmlTextWriterPtr writer = xmlNewTextWriterFilename("library.xml", 0);
xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
xmlTextWriterStartElement(writer, "Library");
xmlTextWriterStartElement(writer, "Comics");
xmlTextWriterFullEndElement(writer);
xmlTexWriterEndElement(writer);
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
}
}
Here's the output:
Code:
library.o: In function `load_library':
library.c:(.text+0x2d): undefined reference to `xmlNewTextWriterFilename'
library.c:(.text+0x4c): undefined reference to `xmlTextWriterStartDocument'
library.c:(.text+0x5d): undefined reference to `xmlTextWriterStartElement'
library.c:(.text+0x6e): undefined reference to `xmlTextWriterStartElement'
library.c:(.text+0x7a): undefined reference to `xmlTextWriterFullEndElement'
library.c:(.text+0x8b): undefined reference to `xmlTexWriterEndElement'
library.c:(.text+0x97): undefined reference to `xmlTextWriterEndDocument'
library.c:(.text+0xa3): undefined reference to `xmlFreeTextWriter'
library.c:(.text+0xaf): undefined reference to `xmlParseFile'
collect2: ld returned 1 exit status
make: *** [eComics] Error 1