When I build a hellworld opencv application, I got "undefined refernce" for about every function I would use. The build command is
g++ `pkg-config opencv --cflags --libs` samples/hello.cpp
Then the issue is fixed by moving the source file to the first parameter
g++ samples/hello.cpp `pkg-config opencv --cflags --libs`
Why is that?
FYI, g++ version
g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.