我尝试在ROS答案上向this question提问没有运气,所以我将在这里尝试。

我正在尝试编译ROS Roboearth package,并且与vision_opencv似乎存在一些链接错误。

当我第一次尝试通过提供的说明进行编译时,由于我使用的是旧编译器,而我没有Fuerte,因此无法进行构建。因此,我将Ubuntu升级到12.04,并更新到了ROS Fuerte。

然后,我意识到12.04没有所需的ros-fuerte-vision-opencv2依赖性。因此,我从源代码编译并构建了OpenCV 2.4.3,效果非常好。然后,我意识到我也无法提取再次从here获得的ros-fuerte-vision-opencv, checkout “fuerte”分支并在/ opt / ros / fuerte / stacks / vision_opencv中进行了编译。

现在,当我尝试通过
rosmake roboearth
我收到以下链接错误。

谢谢您的帮助。可能只是我缺乏C++知识,但是我尝试了所有工作,从检查依赖项到重新设置编译器标志和依赖项的顺序,我似乎无法使它正常工作。

[rosmake-1] Starting >>> ar_pose [ make ]
[ rosmake ] Last 40 lines_vision: 30.7 sec ] [ ar_pose: 4.2 sec ]                                        [ 2 Active 47/103 Complete ]
{-------------------------------------------------------------------------------
  make[3]: Leaving directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  [ 70%] Built target rosbuild_precompile
  make[3]: Entering directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  make[3]: Leaving directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  make[3]: Entering directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  Linking CXX executable ../bin/ar_multi
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `ar_pose::ARSinglePublisher::arInit()':
  /home/sasha/ros/stacks/ccny_vision/ar_pose/src/ar_multi.cpp:140: undefined reference to `cvCreateImage'
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `CvBridge':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:67: undefined reference to `cvCreateImageHeader'
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `~CvBridge':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:73: undefined reference to `cvReleaseImageHeader'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:78: undefined reference to `cvReleaseImage'
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `sensor_msgs::CvBridge::reallocIfNeeded_(_IplImage**, CvSize, int, int)':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:91: undefined reference to `cvReleaseImage'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:97: undefined reference to `cvCreateImage'
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `sensor_msgs::CvBridge::reallocIfNeeded(_IplImage**, int, int)':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:109: undefined reference to `cvGetSize'
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `sensor_msgs::CvBridge::fromImage(sensor_msgs::Image_<std::allocator<void> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:199: undefined reference to `cvInitMatHeader'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:200: undefined reference to `cvGetImage'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:229: undefined reference to `cvCreateMat'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:230: undefined reference to `cvConvertScale'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:236: undefined reference to `cvConvertScale'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:243: undefined reference to `cvCvtColor'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:245: undefined reference to `cvCvtColor'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:247: undefined reference to `cvCvtColor'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:249: undefined reference to `cvCvtColor'
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:253: undefined reference to `cvCvtColor'
  CMakeFiles/ar_multi.dir/src/ar_multi.o:/opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:255: more undefined references to `cvCvtColor' follow
  CMakeFiles/ar_multi.dir/src/ar_multi.o: In function `sensor_msgs::CvBridge::fromImage(sensor_msgs::Image_<std::allocator<void> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
  /opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:293: undefined reference to `cvReleaseMat'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/ar_multi] Error 1
  make[3]: Leaving directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  make[2]: *** [CMakeFiles/ar_multi.dir/all] Error 2
  make[2]: Leaving directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `/home/sasha/ros/stacks/ccny_vision/ar_pose/build'
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package ar_pose written to:
[ rosmake ]    /home/sasha/.ros/rosmake/rosmake_output-20130212-145046/ar_pose/build_output.log
[rosmake-1] Finished <<< ar_pose [FAIL] [ 4.31 seconds ]
[ rosmake ] Halting due to failure in package ar_pose.
[ rosmake ] Waiting for other threads to complete.
[ rosmake ] Last 40 lines_vision: 182.3 sec ]                                                            [ 1 Active 47/103 Complete ]
{-------------------------------------------------------------------------------
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvReleaseMat'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::reshape(int, int, int const*) const'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvSetZero'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::warpPerspective(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Size_<int>, int, int, cv::Scalar_<double> const&)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::getTextSize(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, int, int*)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::zeros(int, int, int)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::_InputArray::_InputArray(cv::MatExpr const&)'
  ../lib/libDVision.so: undefined reference to `cv::read(cv::FileNode const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::DescriptorMatcher::DescriptorCollection::~DescriptorCollection()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::FlannBasedMatcher::train()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvCvtColor'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::MatConstIterator::seek(int const*, bool)'
  ../lib/libDVision.so: undefined reference to `cv::FeatureDetector::~FeatureDetector()'
  ../lib/libDUtilsCV.so: undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
  ../lib/libDVision.so: undefined reference to `cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::initUndistortRectifyMap(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, int, cv::_OutputArray const&, cv::_OutputArray const&)'
  ../lib/libDVision.so: undefined reference to `cv::WriteStructContext::~WriteStructContext()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvCreateImageHeader'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::inv(int) const'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
  ../lib/libDVision.so: undefined reference to `cv::operator<<(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::flann::IndexParams::~IndexParams()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvGetSize'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Mat::deallocate()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::_InputArray::_InputArray(double const&)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cvCreateImage'
  ../lib/libDUtilsCV.so: undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::Algorithm::~Algorithm()'
  ../lib/libObjectDetectorFunctions.so: undefined reference to `cv::FlannBasedMatcher::FlannBasedMatcher(cv::Ptr<cv::flann::IndexParams> const&, cv::Ptr<cv::flann::SearchParams> const&)'
  ../lib/libDVision.so: undefined reference to `cv::Algorithm::set(char const*, bool)'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/ObjectDetector] Error 1
  make[3]: Leaving directory `/home/sasha/ros/stacks/roboearth/re_vision/build'
  make[2]: *** [CMakeFiles/ObjectDetector.dir/all] Error 2
  make[2]: Leaving directory `/home/sasha/ros/stacks/roboearth/re_vision/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `/home/sasha/ros/stacks/roboearth/re_vision/build'
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package re_vision written to:
[ rosmake ]    /home/sasha/.ros/rosmake/rosmake_output-20130212-145046/re_vision/build_output.log
[rosmake-0] Finished <<< re_vision [FAIL] [ 182.31 seconds ]
[ rosmake ] Halting due to failure in package re_vision.

最佳答案

好的,所以我能够解决问题。

首先,我做了sudo apt-get update,我看到了以下消息:
W: Duplicate sources.list entry http://archive.canonical.com/ubuntu/ precise/partner i386 Packages (/var/lib/apt/lists/archive.canonical.com_ubuntu_dists_precise_partner_binary-i386_Packages)
为了解决这个问题,我去了“Synaptic软件包管理器->设置->存储库->其他软件”,并取消选中“规范合作伙伴-由软件中心添加”。

然后又做了sudo apt-get update。这样解决了上述问题。

然后,我转到以下文件/etc/apt/sources.list.d/ros-latest.list,发现该URL已被注释掉。我取消注释以下行deb http://packages.ros.org/ros/ubuntu precise main并再次运行sudo apt-get update

之后,我能够通过apt-get安装roboearth所需的所有依赖项,并能够使用rosmake roboearth成功制作roboearth

关于opencv - ROS Roboearth Ubuntu 12.04 vision_opencv链接错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14841689/

10-11 21:39