Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?
I am starting to develop in C and want to use the libxml2
C-Library for writing a simple xml file.
For this purpose i created seperate sourcefiles which should provide functions to write a xml file.
xmlutils.h:
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>
void writeXML(const char *uri);
xmlutils.c:
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>
void writeXML(const char *uri){
int rc;
xmlTextWriterPtr writer;
xmlChar *tmp;
/* Create a new XmlWriter for uri, with no compression. */
writer = xmlNewTextWriterFilename(uri, 0);
if (writer == NULL) {
printf("testXmlwriterFilename: Error creating the xml writer\n");
return;
}
//more code...
}
in my main.c file i want to use this writeXML function:
#include<stdio.h>
#include<string.h>
#include "xmlutils.h"
main() {
writeXML("test.xml");
}
Im compiling with:
gcc -o myapp main.c xmlutils.c -I/usr/include/libxml2
and i get:
xmlutils.c:(.text+0x19): undefined reference to `xmlNewTextWriterFilename'
collect2: ld returned 1 exit status
What am i doing wrong here?
if i take a look at the usr/include/libxml2/libxml/xmlwriter.h
file there IS the function...
thx