I installed Ubuntu a few days ago, and used apt-get to install build_essentials, opencv, highgui, etc. g++ is 4.6.1, opencv appears to be 2.1.0.. I didn't build opencv from source..
We have some software that uses opencv functionality. Let's pretend the source files are named a.cpp and b.cpp. I compile to a.o and b.o and then put those into a .so library (call it libab.so).
Finally, there's a file with main in it (call it z.cpp). I try to build an executable from it, but I get a ton of "undefined reference" errors to cv:: stuff. My link line looks something like this:
g++ -fPIC -g z.cpp -L../lib -lab -lml -lcvaux -lhighgui -lcv -lcxcore -o z.out
then I get the undefined reference errors (all of which are to cv:: stuff).
The interesting part is if I link directly with my .o files, it builds just fine. So this:
g++ -fPIC -g z.cpp a.o b.o -lml -lcvaux -lhighgui -lcv -lcxcore -o z.out
works.
Everything I've read seems to imply this is likely a link-line-ordering issue, but I have tried all ordering permutations and get the same problem, so I really don't think its my issue, but I could still be wrong. Anyone have any ideas how I can get this to build with my library, and why it would act differently if I build with the complete set of .o files that are in the library successfully, but can't build with the library itself?