Problems compiling OpenCV examples on raspberry pi 2

Thanks for the posting. I was able to compile OF on RPI2

However some of the projects that require math libraries are failing. I tried compiling the addons/openCvExample and the linker was not able to find math libraries.

http://pastebin.com/5zb1pwLv

Linking bin/opencvExample for linuxarmv7l
g++ -o bin/opencvExample 
obj/linuxarmv7l/Release/src/main.o obj/linuxarmv7l/Release/src/ofApp.o 
 ../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvImage.o 
../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvHaarFinder.o 
../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvColorImage.o 
../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvShortImage.o 
../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvContourFinder.o
 ../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvFloatImage.o
 
../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvGrayscaleImage.o
 
../../../libs/openFrameworksCompiled/lib/linuxarmv7l/libopenFrameworks.a
 
 ../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_legacy.a
 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_calib3d.a
 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_objdetect.a
 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_features2d.a
 ../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_video.a
 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a
 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_highgui.a
 ../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_ml.a 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_legacy.a
 ../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_core.a 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_flann.a 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_contrib.a
 ../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_gpu.a 
-Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -pthread 
-L/opt/vc/lib ../../../libs/glfw/lib/linuxarmv7l/libglfw3.a 
../../../libs/kiss/lib/linuxarmv7l/libkiss.a 
../../../libs/poco/lib/linuxarmv7l/libPocoCrypto.a 
../../../libs/poco/lib/linuxarmv7l/libPocoUtil.a 
../../../libs/poco/lib/linuxarmv7l/libPocoNetSSL.a 
../../../libs/poco/lib/linuxarmv7l/libPocoZip.a 
../../../libs/poco/lib/linuxarmv7l/libPocoXML.a 
../../../libs/poco/lib/linuxarmv7l/libPocoNet.a 
../../../libs/poco/lib/linuxarmv7l/libPocoFoundation.a 
../../../libs/rtAudio/lib/linuxarmv7l/libRtAudio.a 
../../../libs/tess2/lib/linuxarmv7l/libtess2.a 
 ../../../libs/poco/lib/linuxarmv7l/libPocoNetSSL.a 
../../../libs/poco/lib/linuxarmv7l/libPocoNet.a 
../../../libs/poco/lib/linuxarmv7l/libPocoCrypto.a 
../../../libs/poco/lib/linuxarmv7l/libPocoUtil.a 
../../../libs/poco/lib/linuxarmv7l/libPocoXML.a 
../../../libs/poco/lib/linuxarmv7l/libPocoFoundation.a  -lz -lgstapp-1.0
 -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -ludev -lfreetype 
-lfontconfig -lsndfile -lopenal -lssl -lcrypto -lpulse-simple -lpulse 
-lasound -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 
-lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 
-lglib-2.0 -lmpg123   -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl 
-lpthread -lfreeimage -lGLESv2 -lGLESv1_CM -lEGL -lopenmaxil -lbcm_host 
-lvcos -lvchiq_arm -lpcre -lrt -lX11 -ldl 
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o):
 In function `cv::getGaussianKernel(int, double, int)':
(.text._ZN2cv17getGaussianKernelEidi+0x1e0): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o):
 In function `cv::bilateralFilter(cv::_InputArray const&, 
cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x348): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o):
 In function `cv::bilateralFilter(cv::_InputArray const&, 
cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x3c6): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o):
 In function `cv::bilateralFilter(cv::_InputArray const&, 
cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x842): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o):
 In function `cv::bilateralFilter(cv::_InputArray const&, 
cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x8b0): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o):
 In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0xd6): undefined reference to `__pow_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o):
 In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0x11a): undefined reference to `__pow_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o):
 In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0x192): undefined reference to `__pow_finite'
collect2: ld returned 1 exit status
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:296: recipe for target 'bin/opencvExample' failed
make[1]: *** [bin/opencvExample] Error 1
make[1]: Leaving directory '/home/pi/dependencies/OF/of_v0.8.4_linuxarmv7l_release/examples/addons/opencvExample'
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:126: recipe for target 'Release' failed
make: *** [Release] Error 2

I have just followed your description; worked fine.

But: When I try to compile an openCV example like opencvExample, I get errors:

ost -lvcos -lvchiq_arm -lpcre -lrt -lX11 -ldl
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o): In function `cv::getGaussianKernel(int, double, int)':
(.text._ZN2cv17getGaussianKernelEidi+0x1e0): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o): In function `cv::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x348): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o): In function `cv::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x3c6): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o): In function `cv::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x842): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(smooth.o): In function `cv::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, double, double, int)':
(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x8b0): undefined reference to `__exp_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o): In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0xd6): undefined reference to `__pow_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o): In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0x11a): undefined reference to `__pow_finite'
../../../addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_imgproc.a(color.o): In function `cv::initLabTabs() [clone .part.1]':
(.text._ZN2cvL11initLabTabsEv.part.1+0x192): undefined reference to `__pow_finite'
collect2: ld returned 1 exit status
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:296: recipe for target 'bin/opencvExample' failed
make[1]: *** [bin/opencvExample] Error 1
make[1]: Leaving directory '/home/pi/of_v0.8.4_linuxarmv7l_release/examples/addons/opencvExample'
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:126: recipe for target 'Release' failed
make: *** [Release] Error 2

Please help me, what is to be done to make it work?

Other OpenCV thread

I had the same issue (as I assume all pi2 users will have in the short term). In this other thread, ‘fieldOfView’ posted a link to 12 modified files. After replacing these on my pi 2, openCV examples ran without issue.

The modified files can be downloaded here:
http://files.fieldofview.com/temp/ofxopencv_armv7_libs.tar.gz

1 Like