undefined reference to 'cvCanny' undefined reference to 'cvCbrt'

lid@lid-VirtualBox:~/share/lide/appsprogram/face-detction$ make 

arm-oe-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=softfp -mfpu=neon --sysroot=/home/lid/gcc/sdk8053/sysroots/armv7a-vfp-neon-oe-linux-gnueabi -o face-rec src/objectDetection.o  -O2 -fexpensive-optimizations -frename-registers -fomit-frame-pointer -ftree-vectorize   -finline-functions -finline-limit=64   -Wno-error=maybe-uninitialized   -std=c++11  -O2 -fexpensive-optimizations -frename-registers -fomit-frame-pointer -ftree-vectorize   -finline-functions -finline-limit=64   -Wno-error=maybe-uninitialized   -g -pthread -Wall  -rdynamic -funwind-tables -Dunused="attribute((unused__))" -I./usr/include/opencv -I./usr/inc/opencv/opencv2 -I./usr/include   -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -L./usr/lib/   -lopencv_core -ldl -lm -lz -lopencv_calib3d  -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui  -lopencv_imgcodecs -lopencv_imgproc  -lopencv_ml  -lopencv_objdetect  -lopencv_photo  -lopencv_shape -lopencv_stitching -lopencv_superres  -lopencv_video -lopencv_videostab -lopencv_videoio  -lIlmImf -llibjasper -llibtiff -llibpng -llibjpeg -llibwebp -lzlib -lrt -lpthread -pthread -lm -ldl 

./usr/lib//libopencv_imgproc.a(color.cpp.obj):color.cpp:function cv::initLabTabs() [clone .part.0]: error: undefined reference to 'cvCbrt'

./usr/lib//libopencv_imgproc.a(color.cpp.obj):color.cpp:function cv::initLabTabs() [clone .part.0]: error: undefined reference to 'cvCbrt'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cv::logPolar(cv::_InputArray const&, cv::OutputArray const&, cv::Point<float>, double, int): error: undefined reference to 'cv::cartToPolar(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, bool)'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cv::logPolar(cv::_InputArray const&, cv::OutputArray const&, cv::Point<float>, double, int): error: undefined reference to 'cv::log(cv::_InputArray const&, cv::_OutputArray const&)'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cv::linearPolar(cv::_InputArray const&, cv::OutputArray const&, cv::Point<float>, double, int): error: undefined reference to 'cv::cartToPolar(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, bool)'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cvLogPolar: error: undefined reference to 'cvCartToPolar'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cvLogPolar: error: undefined reference to 'cvLog'

./usr/lib//libopencv_imgproc.a(imgwarp.cpp.obj):imgwarp.cpp:function cvLinearPolar: error: undefined reference to 'cvCartToPolar'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::HaarEvaluator::computeChannels(int, cv::_InputArray const&): error: undefined reference to 'cv::integral(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int)'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::HaarEvaluator::computeChannels(int, cv::_InputArray const&): error: undefined reference to 'cv::integral(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int)'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::HaarEvaluator::computeChannels(int, cv::_InputArray const&): error: undefined reference to 'cv::integral(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int)'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::HaarEvaluator::computeChannels(int, cv::_InputArray const&): error: undefined reference to 'cv::integral(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int)'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::BaseCascadeClassifier::~BaseCascadeClassifier(): error: undefined reference to 'cv::Algorithm::~Algorithm()'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:function cv::CascadeClassifierImpl::CascadeClassifierImpl(): error: undefined reference to 'cv::Algorithm::Algorithm()'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:vtable for cv::CascadeClassifierImpl: error: undefined reference to 'cv::Algorithm::save(cv::String const&) const'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:vtable for cv::CascadeClassifierImpl: error: undefined reference to 'cv::Algorithm::getDefaultName() const'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:typeinfo for cv::BaseCascadeClassifier: error: undefined reference to 'typeinfo for cv::Algorithm'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:vtable for cv::BaseCascadeClassifier: error: undefined reference to 'cv::Algorithm::save(cv::String const&) const'

./usr/lib//libopencv_objdetect.a(cascadedetect.cpp.obj):cascadedetect.cpp:vtable for cv::BaseCascadeClassifier: error: undefined reference to 'cv::Algorithm::getDefaultName() const'

./usr/lib//libopencv_objdetect.a(haar.cpp.obj):haar.cpp:function cvHaarDetectObjectsForROC(void const, CvHaarClassifierCascade, CvMemStorage, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, CvSize, CvSize, bool): error: undefined reference to 'cvIntegral'

./usr/lib//libopencv_objdetect.a(haar.cpp.obj):haar.cpp:function cvHaarDetectObjectsForROC(void const
, CvHaarClassifierCascade, CvMemStorage, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, CvSize, CvSize, bool): error: undefined reference to 'cvIntegral'

./usr/lib//libopencv_objdetect.a(haar.cpp.obj):haar.cpp:function cvHaarDetectObjectsForROC(void const, CvHaarClassifierCascade, CvMemStorage, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, CvSize, CvSize, bool): error: undefined reference to 'cvCanny'

./usr/lib//libopencv_objdetect.a(haar.cpp.obj):haar.cpp:function cvHaarDetectObjectsForROC(void const
, CvHaarClassifierCascade, CvMemStorage, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, CvSize, CvSize, bool): error: undefined reference to 'cvIntegral'

collect2: error: ld returned 1 exit status

make: *** [face-rec] Error 1


opencv3.2交叉编译遇到上述无法找到问题,本项目中OpenCV中使用的是生成的静态库。

编译方法,

是在cmake的时候

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=OFF -D BUILD_SHARED_LIBS=NO -D BUILD_PNG=ON -D BUILD_JASPER=ON -D BUILD_JPEG=ON -D BUILD_TIFF=ON -D BUILD_ZLIB=ON -D WITH_JPEG=ON -D WITH_PNG=ON -D WITH_JASPER=ON -D WITH_TIFF=ON ..

将build-shared-libs 关掉,在cmake-gui中将勾去掉。

生成的目录其中lib里边都是opencv的静态库,share里边有第三方的libjpeg的库

lid@lid-VirtualBox:~/build-opencv3/insatll$ ls
bin  include   lib  LICENSE  share
lid@lid-VirtualBox:~/build-opencv3/insatll$ ls lib/
a                    libopencv_core.a        libopencv_flann.a    libopencv_imgcodecs.a  libopencv_ml.a         libopencv_photo.a  libopencv_stitching.a  libopencv_video.a    libopencv_videostab.a
libopencv_calib3d.a  libopencv_features2d.a  libopencv_highgui.a  libopencv_imgproc.a    libopencv_objdetect.a  libopencv_shape.a  libopencv_superres.a   libopencv_videoio.a  so
lid@lid-VirtualBox:~/build-opencv3/insatll$ ls share/OpenCV/3rdparty/lib/
libIlmImf.a  liblibjasper.a  liblibjpeg.a  liblibpng.a  liblibtiff.a  liblibwebp.a  libzlib.a
lid@lid-VirtualBox:~/build-opencv3/insatll$ 

我们将这些库拷贝到Makefile下的编译环境下。

其中Makefile的顺序一定要注意。

objdetect depends upon imgproc

这样写是不会出问题的。

LDFLAGS +=  -lopencv_calib3d   -lopencv_features2d   -lopencv_imgcodecs   -lopencv_ml  -lopencv_objdetect  -lopencv_photo  

LDFLAGS +=  -lopencv_shape -lopencv_stitching -lopencv_superres  -lopencv_video -lopencv_videostab -lopencv_videoio   -lopencv_highgui

LDFLAGS += -lIlmImf -llibjasper -llibtiff -llibpng -llibjpeg -llibwebp -lzlib -lopencv_imgproc -lopencv_flann -lopencv_core



sitemap