Attention: Answers.ros.org is deprecated as of August the 11th, 2023. Please visit robotics.stackexchange.com to ask a new question. This site will remain online in read-only mode during the transition and into the foreseeable future. Selected questions and answers have been migrated, and redirects have been put in place to direct users to the corresponding questions on Robotics Stack Exchange. Additional details are available here.
You have to declare opencv2 as an external dependency in your CMakeLists.txt. Similar to eigen and opencv in this example: http://wiki.ros.org/catkin/CMakeLists.txt#catkin_package.28.29
You will have to add opencv2 also to the target_link_libraries (in CMakeLists.txt)