Pasted from my previous blog on 2 August 2010.
Since one last month I discover new mobile platform from Samsung, Bada. With basic skill as amateur Java Programmer I just have very basic skill in c/c++ programming that is used as lingua franca of Bada. Perhaps I know little bit knowledge about pointer. But I lost when need to discover build, link related problem.
One time I need to build application that have parse xml. I put the xml code in OnInitializing method that is extends from Osp::Ui::Controls::Form and I also not forget to include FXml.h at my header file and using namespace Osp::Xml in my cpp file. Here is snapshot of the code:
result MyXmlForm::OnInitializing(void) {
xmlDoc* doc = null;
xmlXPathContextPtr xpathCtx;
xmlXPathObjectPtr xpathObj;
doc = xmlReadFile(“/Home/test.xml”, null, 0); // error here
if (doc == NULL) {
AppLog(“Failed to load xml doc!”);
}
xpathCtx = xmlXPathNewContext(doc); // error
if (xpathCtx == NULL) {
AppLog(“Error: unable to create new XPATH context”);
xmlFreeDoc(doc); //error
return (E_IO);
}
xpathObj = xmlXPathEvalExpression((xmlChar*) “//title”, xpathCtx); //error
if (xpathObj == NULL) {
AppLog(“Error: unable to evaluate xpath expression”);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
return (E_IO);
}
get_xpath_titles(xpathObj->nodesetval);
xmlFreeDoc(doc); // error
xmlCleanupParser(); // error
return E_SUCCESS;
}
Here are the errors:
undefined reference to `xmlReadFile'
undefined reference to `xmlFreeDoc’
undefined reference to `xmlXPathNewContext’
undefined reference to `xmlXPathEvalExpression’
undefined reference to `xmlXPathFreeContext’
undefined reference to `xmlCleanupParser’
This evening I spent about two hour to make above code work. Like I have said, Bada itself actually has provide xml library with namespace Osp::Xml which is subset from libxml2. When I finish type the code I stuck when have to face undefined reference to bla bla bla error relate to method call from Osp::Xml. I already make sure that I have include FXml.h in my header declaration and also state using namespace Osp::Xml in my source code. After spending sometime researching with very minimum information from Bada Documentation and also all internet site I found I need to link FXml library in project properties. Then build problem dissapear and my code can run smooth now. Yippie.
You need to include FXml.h and use namespace Osp::Xml
ReplyDelete