码迷,mamicode.com
首页 > 其他好文 > 详细

error: ld returned 1 exit status

时间:2017-09-12 13:38:40      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:log   mat   参考   table   dir   def   oca   reference   pack   

wj@wj-Inspiron-5437:~/Downloads/LBD_Descriptor/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wj/Downloads/LBD_Descriptor/build
wj@wj-Inspiron-5437:~/Downloads/LBD_Descriptor/build$ make
[ 66%] Built target LineMatchingLib
Linking CXX executable TestLineMatchingAlgorithm
CMakeFiles/TestLineMatchingAlgorithm.dir/TestLineMatchingAlgorithm.cpp.o: In function `cv::String::String(char const*):
TestLineMatchingAlgorithm.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x30): undefined reference to `cv::String::allocate(unsigned long)CMakeFiles/TestLineMatchingAlgorithm.dir/TestLineMatchingAlgorithm.cpp.o: In function `cv::String::String(std::string const&):
TestLineMatchingAlgorithm.cpp:(.text._ZN2cv6StringC2ERKSs[_ZN2cv6StringC5ERKSs]+0x34): undefined reference to `cv::String::allocate(unsigned long)CMakeFiles/TestLineMatchingAlgorithm.dir/TestLineMatchingAlgorithm.cpp.o: In function `main:
TestLineMatchingAlgorithm.cpp:(.text.startup+0xfe): undefined reference to `cv::imread(cv::String const&, int)TestLineMatchingAlgorithm.cpp:(.text.startup+0x12a): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0x21e): undefined reference to `cv::imread(cv::String const&, int)TestLineMatchingAlgorithm.cpp:(.text.startup+0x24a): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0x624): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)TestLineMatchingAlgorithm.cpp:(.text.startup+0x7f3): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)TestLineMatchingAlgorithm.cpp:(.text.startup+0x89d): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)TestLineMatchingAlgorithm.cpp:(.text.startup+0x8a5): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0x939): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)TestLineMatchingAlgorithm.cpp:(.text.startup+0x941): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0xa96): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0xac9): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0xb53): undefined reference to `cv::String::deallocate()TestLineMatchingAlgorithm.cpp:(.text.startup+0xb96): undefined reference to `cv::String::deallocate()libLineMatchingLib.so: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)libLineMatchingLib.so: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, cv::Mat const&)libLineMatchingLib.so: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)libLineMatchingLib.so: undefined reference to `cv::operator<<(cv::FileStorage&, cv::String const&)collect2: error: ld returned 1 exit status
make[2]: *** [TestLineMatchingAlgorithm] Error 1
make[1]: *** [CMakeFiles/TestLineMatchingAlgorithm.dir/all] Error 2
make: *** [all] Error 2

阅读错误之后,感觉是opencv本的问题(由于我安装了两个版本opencv-2.4.9 and opencv-3.1.0),搜了相关问题,然后修改了CMakeList.txt,解决了此问题。

参考了这个博客:http://www.cnblogs.com/xzd1575/p/5555523.html

CMake下指定Opencv版本

关键文件:OpenCVConfig.cmake。在opencv编译好后,所在目录中一般会有一个叫OpenCVConfig.cmake的文件,这个文件中指定了CMake要去哪里找OpenCV,其.h文件在哪里等.

只要让CMake找到这个文件,这个文件就指定了Opencv的所有路径,因此设置OpenCV_DIR为包含OpenCVConfig.cmake的目录,如在我的C++工程CMakeLists.txt中添加

set(OpenCV_DIR "/home/wj/gxcode/slambook/3rdparty/opencv-3.1.0/build/")   //找OpenCVConfig.cmake目录

注意,将其添加在project(MyProjectName)之前。

如CMakeLists.txt内容如下:

PROJECT(LILIANTESTS)
cmake_minimum_required(VERSION 2.8)
set(OpenCV_DIR "/home/wj/opencv-3.1.0/build/")
find_package( OpenCV REQUIRED )
add_executable( camera camera.cpp )
target_link_libraries( camera ${OpenCV_LIBS} )

 

error: ld returned 1 exit status

标签:log   mat   参考   table   dir   def   oca   reference   pack   

原文地址:http://www.cnblogs.com/Jessica-jie/p/7509460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!