- 论坛徽章:
- 0
|
我的源程序是这样的
#include<libxml/parser.h>//使用libxml库
#include<libxml/tree.h>
int main(int argc, char** argv)
{
xmlDocPtr doc = NULL; /* document pointer */
xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */
// Creates a new document, a node and set it as a root node
doc = xmlNewDoc(BAD_CAST "1.0" ;
root_node = xmlNewNode(NULL, BAD_CAST "root" ;
xmlDocSetRootElement(doc, root_node);
//creates a new node, which is "attached" as child node of root_node node.
xmlNewChild(root_node, NULL, BAD_CAST "node1",BAD_CAST "content of node1" ;
// xmlNewProp() creates attributes, which is "attached" to an node.
node=xmlNewChild(root_node, NULL, BAD_CAST "node3", BAD_CAST"node has attributes" ;
xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes" ;
//Here goes another way to create nodes.
node = xmlNewNode(NULL, BAD_CAST "node4" ;
node1 = xmlNewText(BAD_CAST"other way to create content" ;
xmlAddChild(node, node1);
xmlAddChild(root_node, node);
//Dumping document to stdio or file
xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1);
/*free the document */
xmlFreeDoc(doc);
xmlCleanupParser();
xmlMemoryDump();//debug memory for regression tests
return(0);
}
错误提示为:[root@cloud1 mycode]# gcc -o test main.c fileprocess.c
/tmp/ccCZCM5v.o: In function `xmlparse':
fileprocess.c .text+0x2b): undefined reference to `xmlNewDoc'
fileprocess.c .text+0x43): undefined reference to `xmlNewNode'
fileprocess.c .text+0x5 : undefined reference to `xmlDocSetRootElement'
fileprocess.c .text+0x7d): undefined reference to `xmlNewChild'
fileprocess.c .text+0xa2): undefined reference to `xmlNewChild'
fileprocess.c .text+0xc2): undefined reference to `xmlNewProp'
fileprocess.c .text+0xd7): undefined reference to `xmlNewNode'
fileprocess.c .text+0xe7): undefined reference to `xmlNewText'
fileprocess.c .text+0xfc): undefined reference to `xmlAddChild'
fileprocess.c .text+0x10e): undefined reference to `xmlAddChild'
fileprocess.c:(.text+0x142): undefined reference to `xmlSaveFormatFileEnc'
fileprocess.c:(.text+0x14d): undefined reference to `xmlFreeDoc'
fileprocess.c:(.text+0x152): undefined reference to `xmlCleanupParser'
fileprocess.c:(.text+0x157): undefined reference to `xmlMemoryDump'
|
|