OpenCV 2.4 : undefined reference to cvRand-Collection of common programming errors

I can’t find the file I have to include to my code to get cvRand (and all other related functions, such as cvRandInit … ) to be recognized by the compiler. It’s weird, because in the past this code used to work as is. Must be an issue with OpenCV2.4.

Also, when I right-clic on cvRand (I work with Qt Creator) and ask to follow the symbol under the cursor, the IDE open a file called compat.hpp. I have several files named compat.hpp, so I don’t know which one I have to include. My OS is Ubuntu 11.04.

So far, I included core.hpp, highgui.hpp, and cv.h.

I googled on this, but couldn’t find any related issue… so I guess this is not an issue, and I just miss something stupid.

  1. The includes were obviously right, I figured that it has to be a lib problem, by guessing I found that I had to add libopencv_legacy.so. Everything works fine now, thx stackoverflow.

Originally posted 2013-11-06 03:11:31.