未定义的一些opencv函数的引用

时间:2015-03-10 19:40:17

标签: c++ eclipse opencv linker

我正在尝试编译Ubuntu 14.04环境中opencv示例附带的'motemple.c'。我认为opencv已经正确安装;大多数程序都按预期运行。但是,在编译上述文件时,会针对多个函数引发错误“未定义引用”。以下是编译的输出:

Building target: ACTION_detection1
Invoking: Cross G++ Linker
g++ -L/usr/local/lib -o "ACTION_detection1"  ./opencvexample/MotionSegmentation.o   -lopencv_core -lopencv_photo -lopencv_videoio -lopencv_videostab -lopencv_imgcodecs -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
./opencvexample/MotionSegmentation.o: In function `update_mhi':
/media/thanuja/DTR_DATA/ACTION-TV/ACTIONDETECTION/Implementations/ACTION_detection1/Debug/../opencvexample/MotionSegmentation.cpp:103: undefined reference to `cvUpdateMotionHistory'
/media/thanuja/DTR_DATA/ACTION-TV/ACTIONDETECTION/Implementations/ACTION_detection1/Debug/../opencvexample/MotionSegmentation.cpp:105: undefined reference to `cvUpdateMotionHistory'
/media/thanuja/DTR_DATA/ACTION-TV/ACTIONDETECTION/Implementations/ACTION_detection1/Debug/../opencvexample/MotionSegmentation.cpp:114: undefined reference to `cvCalcMotionGradient'
/media/thanuja/DTR_DATA/ACTION-TV/ACTIONDETECTION/Implementations/ACTION_detection1/Debug/../opencvexample/MotionSegmentation.cpp:123: undefined reference to `cvSegmentMotion'
/media/thanuja/DTR_DATA/ACTION-TV/ACTIONDETECTION/Implementations/ACTION_detection1/Debug/../opencvexample/MotionSegmentation.cpp:149: undefined reference to `cvCalcGlobalOrientation'
collect2: error: ld returned 1 exit status
make: *** [ACTION_detection1] Error 1

可以看出,我已将所有opencv库链接到mu Eclipse项目。我也尝试了here提供的命令行解决方案,但仍然得到相同的错误。

1 个答案:

答案 0 :(得分:0)

它们已被替换为主存储库中的opencv_contrib。您可以在optflow模块中找到它们。

注意:cvUpdateMotionHistorycvCalcMotionGradient等是OpenCV 1.x API函数的名称,它们现在已过时/过时,因此请尝试通过替换为cv::updateMotionHistory来避免它们, cv::calcMotionGradient等等。