undefined reference to 'function'

Jun 12, 2012 at 2:14pm
i want to use one program as a shared library for an other program.

i started as follows:
i have a application which i have compiled using

/usr/bin/g++ -I/usr/include/libxml2 -fpermissive -ffriend-injection -Wformat -Wno-deprecated -Xlinker -zmuldefs -fPIC -c abc.cpp

then i have created a shared object library from the objects i get from this file using this command

g++ -fPIC -Xlinker -zmuldefs -shared -o libabc.so abc.o
after this i get the libabc.so file which i copy to the
sudo cp libabc.so /usr/local/lib/libabc.so


now when i compile my orignal application which will use this newly created library libabc.so using this command
/usr/local/lib/libabd.so: undefined reference to `xmlXPathNewContext' i get errors for all the functions i used of that included library libxml2 in the first application and the function which has this undefined reference is actually the library i include in the first program using -I/usr/include/libxml2

so kindly anyone guide me where i need corrections
Jun 12, 2012 at 2:59pm
You aren't linking to libxml. All I can say is that.
Jun 12, 2012 at 3:35pm
can you help me how should i do that :)
Jun 12, 2012 at 8:29pm
You should add something like a "-l libxml2" to your command line, and add your /usr/lib/libxml2 to your library folders. I don't know what's that command anyways, maybe it's -L/usr/lib/libxml2
Jun 13, 2012 at 1:47am
agree with EssGeEich...
Jun 13, 2012 at 2:27am
-l strips lib and .so
It should be simply -lxml2

/usr/lib/ should be already on the lib path.
Jun 13, 2012 at 12:12pm
/usr/lib/ should be already on the lib path.

What if the lib is in /usr/lib/libxml2/ ? (Not on Linux from some time huh)
Last edited on Jun 13, 2012 at 12:12pm
Topic archived. No new replies allowed.