unable to link static opencv
I have compiled successfully the new rc version of opencv with the static libraries enabled. However, when I am trying to link my application to these libraries I am getting a many errors:
....
....
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x5a2): undefined reference to `cv::getOptimalDFTSize(int)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0xe81): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1a2a): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1b01): undefined reference to `cv::mulSpectrums(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, bool)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1b62): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplateMask(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)':
(.text._ZN2cvL17matchTemplateMaskERKNS_11_InputArrayES2_RKNS_12_OutputArrayEiS2_+0x2835): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)':
(.text._ZN2cv13matchTemplateERKNS_11_InputArrayES2_RKNS_12_OutputArrayEiS2_+0x1e80): undefined reference to `ippicviCrossCorrNorm_8u32f_C1R'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)':
(.text._ZN2cv13matchTemplateERKNS_11_InputArrayES2_RKNS_12_OutputArrayEiS2_+0x1e9e): undefined reference to `ippicviCrossCorrNormGetBufferSize'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)':
(.text._ZN2cv13matchTemplateERKNS_11_InputArrayES2_RKNS_12_OutputArrayEiS2_+0x1ead): undefined reference to `ippicvsMalloc_8u'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)':
(.text._ZN2cv13matchTemplateERKNS_11_InputArrayES2_RKNS_12_OutputArrayEiS2_+0x1efd): undefined reference to `ippicvsFree'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray ...
can you show your makefile, or whatever you're using ?
with static linking, the order of libs is important (stuff like zlib or core, which are referenced from other libs, has to go at the end of the list)
@berak I am trying to compile the application with the following command
g++ -o app main.cpp 'pkg-config --static --cflags --libs opencv'
. I did not know that there should be a specific order of the linked libs. Do you know if there is any sample somewhere of how the libs should be ordered, which I can use.if you do
pkg-config --static --cflags --libs opencv
on the console, what is the outcome ?this one:
-I/usr/include/opencv -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_hal -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab -lopencv_viz -lopencv_adas -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_datasets -lopencv_face -lopencv_latentsvm -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_xfeatures2d -lopencv_ximgproc -lopencv_xobjdetect -lopencv_xphoto
what happens, if you do it manually, and move core and imgproc to the end of the list ? i got: g++ -std=c++0x cv.cpp -I ocv3/include -L ocv3/lib -L ocv3/share/OpenCV/3rdparty/lib -lopencv_imgcodecs -lopencv_calib3d -lopencv_ccalib -lopencv_xfeatures2d -lopencv_features2d -lopencv_xobjdetect -lopencv_flann -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_xphoto -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_bgsegm -lopencv_face -lopencv_saliency -lopencv_stitching -lopencv_superres -lopencv_tracking -lopencv_ximgproc -lopencv_shape -lopencv_text -lopencv_optflow -lopencv_reg -lopencv_bioinspired -lopencv_imgproc -lopencv_core -lopencv_hal -ljpeg -llibpng -llibtiff -llibwebp -lippicv -lrt -ldl -lz -lpthread -o cv
@berak nope same output. Is it compiling in your case?
it does not seem to find any of the 3rd party libs on your side
just trying with ipp, trouble there atm
compiles now. edited the comment above with current state.
libippicv is in -L ocv3/share/OpenCV/3rdparty/lib
http://sugarcoatedchili.herokuapp.com...
I added:
-L/usr/share/opencv/3rdparty/lib -lippicv
same issues. Btw it does not find the following libs as well/usr/bin/ld: cannot find -llibpng /usr/bin/ld: cannot find -llibtiff /usr/bin/ld: cannot find -llibwebp