OpenCV 2.3 Compiling Issue - Undefined Refence - Ubuntu 11.10

I am guessing that at least some of the libraries in the output of

pkg-config opencv --libs

are archive libraries. It is incorrect to put archive libraries before sources that need them (test_1.cpp in this case): the order of sources and libraries on the link line matters.

Try

g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs` 

I was having the same problem, but I found out pkg-config opencv --cflags is printing "-I/usr/include/opencv" instead of "-I/usr/include/opencv2"... Maybe a package bug on Ubuntu?