The make and install process appeared to work fine, however i am having problems with missing libraries. Here is a simple program i was using to test with:
I run G++ to compile it as per the guide:
g++ -Wall -I/usr/include/collada test.cpp -lcollada_dae -lcollada_dom -lcollada_dae -lcollada_STLDatabase -lcollada_stdErrPlugin -lcollada_LIBXMLPlugin -lxml2 -o test
I am getting the following linker error:
/usr/bin/ld: cannot find -lcollada_STLDatabase
upon removing -lcollada_STLDatabase from the command, it complains about -lcollada_stdErrPlugin and then -lcollada_LIBXMLPlugin.
Removing all three of those allows it to compile, but when i add
daeInt error = collada_dom->load(“file:///home/kellyj2/Desktop/collada/cube.dae”);
i get:
./test: symbol lookup error: ./test: undefined symbol: xmlTextReaderGetParserLineNumber
So i am stumped. I cannot find any mention of or how to install these plugins on the forum or the internet.
I thought it might be this too, I had libxml but it was not installed in the usual location
So I have now done an apt-get-install libxml2-dev, and tested like so:
My program currently:
#include <stdio.h>
#include <libxml/parser.h>
#include <dae.h>
#include <dom/domCOLLADA.h>
#include <dom/domProfile_COMMON.h>
int main(int argc, char **argv)
{
printf("Testing
");
xmlDoc *doc = NULL;
xmlNode *root_element = NULL;
doc = xmlReadFile("/home/kellyj2/Desktop/collada/cube.dae", NULL, 0);
root_element = xmlDocGetRootElement(doc);
printf("LibXML says root element name is: %s
", root_element->name);
DAE *collada_dom;
printf("Initialize collada_dom:
");
collada_dom = new DAE();
printf("Loading document
");
daeInt error = collada_dom->load("/home/kellyj2/Desktop/collada/cube.dae");
printf("The error number is %d", error);
delete collada_dom;
xmlFreeDoc(doc);
xmlCleanupParser();
}
the libxml2 stuff seems to work fine, the output is:
~/Desktop/collada>./test
Testing
LibXML says root element name is: COLLADA
Initialize collada_dom:
Loading document
./test: symbol lookup error: ./test: undefined symbol: xmlTextReaderGetParserLineNumber
zsh: exit 127 ./test
Still the same error.
If i use an invalid file name, it will instead fail with error -100.
It sounds like you’re compiling with one version of libxml, but linking to a different (older) version.
Try running “ldd programName” on your exe and see what libxml you’re linking to. Mine says this: “libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb7768000)”. Yours should say something similar.
The latest code in svn comes with a unit test library that you can build for Linux. Try running “make -k -C domPath/test/build/linux” (replace domPath with the path to the DOM on your machine of course), and that’ll generate a program at “domPath/bin/linux_1.4_debug/domTest”, which you can run like this: “domTest -all”. It should print “All tests passed” when it’s done. If that fails there’s a bigger problem somewhere, but if it works then you have a working DOM client app you can use as a reference. You can run ldd on it to see what’s different between the unit test program and your client app.
Indeed you are right, i did a whereis on libxml2 and it pointed to the wrong copy. thanks for all your help with this. As you could probably guess, I have not been using Linux for too long.
~/Desktop/collada>./test
Testing
LibXML says root element name is: COLLADA
Initialize collada_dom:
Loading document
The error number is 0
i re-ordered my LD_LIBRARY_PATH to put /usr/lib first. It even made some other minor problems i was having go away.
Heh no prob. I just started using Linux as my primary development platform earlier this year. Working with C++ in particular is very different under Linux than it is under Windows with Visual Studio; the build architectures are totally different. Anyway if you stick with it I think you’ll find it’s nicer, as long as you’re willing to invest the time into properly setting up a development environment and customizing it for your needs (I mostly use emacs).
Anyway good luck with it and let me know if you have any other problems.