undefined reference to everything
Hi,
I have a package in my workspace that uses openCV and cv_bridge. I needed the cuda module of openCV, but it doesn't exist in the default openCV of ROS. I installed another version of openCV that included the cuda modules, I tried to link my workspace and my package to the new openCV and I had lots of errors like "undefined reference to 'cv_bridge::...' ", "undefined reference to 'ros::init::...' ", "undefined reference to 'rosbag::...' ". I tried to solve the problems but I wasn't able, so I tried to return to the default openCV (it worked fine with my package before I tried to use cuda, etc.), but it gives the same errors now. I have uninstalled and reinstalled ROS, deleted my workspace and the package and I have created them again, but I have the same errors. I have all the dependencies in the CMakeLists.txt.
________
EDIT
For more information, I have created now a new node with a loop that does nothing but ros::spinOnce(); loop_rate.sleep();
in a different package, and I have the same undefined reference to
errors about ros::init(...)
and ros::NodeHandle::NodeHandle(...)
.
________
EDIT 2
I have exported my package to another computer with ros and it does work, so I think it is a problem in my ros installation or something wrong in the configuration of the computer or ubuntu (maybe CMake, g++ or gcc?). Please does anyone know which could be the problem? Please I really need help!
________
These are some of the errors:
undefined reference to 'cv_bridge::toCvCopy(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, std::string const&)'
undefined reference to 'ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
undefined reference to 'ros::init(int&, char**, std::string const&, unsigned int)'
undefined reference to 'ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
undefined reference to 'rosbag::Bag::open(std::string const&, unsigned int)'
undefined reference to 'rosbag::TypeQuery::TypeQuery(std::string const&)'
undefined reference to 'rosbag::MessageInstance::getTopic() const'
undefined reference to 'pcl_ros::transformPointCloud(std::string const&, sensor_msgs::PointCloud2_<std::allocator<void> > const&, sensor_msgs::PointCloud2_<std::allocator<void> >&, tf::TransformListener const&)'
undefined reference to 'pcl::PCDWriter::writeBinary(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&)'
undefined reference to 'pcl::PCDWriter::writeASCII(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, int)'
undefined reference to 'rosbag::MessageInstance::getMD5Sum() const'
undefined reference to 'rosbag::Bag::readField(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, std::string const&, bool, std::string&) const'
undefined reference to 'rosbag::Bag::readField(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, std::string ...
Which OpenCV version is found when you compile? You can check the version in CMakeCache.txt,
grep "OpenCV_DIR" build/CMakeCache.txt
. Make sure you require a specific version so that you find the one with your CUDA modules enabled.Thank you for your reply. This is what I found there: //The directory containing a CMake configuration file for OpenCV. OpenCV_DIR:PATH=/opt/ros/kinetic/share/OpenCV-3.3.1-dev It is the default openCV. I'm not even sure if I need a specific version, but the default doesn't have anything about cuda.
If you need CUDA then you need to compile/install your own version of OpenCV. Then you need to specify to CMake which version of OpenCV you want to use. Either by setting the find_package to a specific version.
or by specifying the OpenCV path when calling
catkin_make
; eg:catkin_make -DOpenCV_DIR=/usr/local/opencv_install_path
. You should also tweak your CMake file to make sure that the version you have found does have CUDA: https://tinyurl.com/ya4drp8aI know, and that's why I installed another version of OpenCV that had CUDA, and I called
catkin_make -DOpenCV_DIR=...
, but since I did it I have thoseundefined reference to
errors, and I don't know why. I did a catkin_make clean and now I use the default OpenCV again, but the errors persist.So I don't know if I have changed something important and now my package doesn't find the
ros::init
for example, and that's my main problem now.For more information, I have created now a new node with a loop that does nothing but
ros::spinOnce(); loop_rate.sleep();
in a different package, and I have the sameundefined reference to
errors aboutros::init(...)
andros::NodeHandle::NodeHandle(...)