Unable to link opencvExample on armv7

I cannot get /examples/addons/opencvExample to link. Even though libm is linked ( -lm ), I get undefined reference errors on ___exp_finite, __log_finite, etc. This seems to be specific to armv7, as the same example works on armv6.

Linker command on amrv7:

Linking bin/opencvExample for linuxarmv7l
g++ -o bin/opencvExample obj/linuxarmv7l/Release/src/ofApp.o obj/linuxarmv7l/Release/src/main.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/ofxCvHaarFinder.o ../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvGrayscaleImage.o ../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvImage.o ../../../addons/obj/linuxarmv7l/Release/ofxOpenCv/src/ofxCvColorImage.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 ../../../libs/glfw/lib/linuxarmv7l/libglfw3.a ../../../libs/kiss/lib/linuxarmv7l/libkiss.a ../../../libs/poco/lib/linuxarmv7l/libPocoCrypto.a ../../../libs/poco/lib/linuxarmv7l/libPocoXML.a ../../../libs/poco/lib/linuxarmv7l/libPocoFoundation.a ../../../libs/poco/lib/linuxarmv7l/libPocoNetSSL.a ../../../libs/poco/lib/linuxarmv7l/libPocoUtil.a ../../../libs/poco/lib/linuxarmv7l/libPocoZip.a ../../../libs/poco/lib/linuxarmv7l/libPocoNet.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  -pthread -lz -lgstapp-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -ludev -lsndfile -lopenal -lportaudio -lm -lpthread -lssl -lcrypto -lpulse-simple -lpulse -lasound -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lmpg123   -lX11 -lXrandr -lXxf86vm -lXi -lfreeimage -lGLESv1_CM -lGLESv2 -lEGL

Here’s an excerpt of the resulting error:

../../../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
make[1]: *** [bin/opencvExample] Error 1
make: *** [Release] Error 2

I tried both the “vanilla” openframeworks master branch and @digitalhack’s special allwinner (sunxi) branch with the exact same results.

I have tried moving the -lm directive further to the front and further to the back with no success. The same example compiles just fine on a raspberry pi (armv6). I even checked the exported methods of libm.so against the same file on a raspberryPi so it does not seem that libm.so is faulty either.

I worked around the issue by rebuilding libopencv*.a from source. Now the example (and anything that uses ofxOpenCV) compiles and links as expected. In other words: libm had little to do with it :-/

I am still interested to know if the current set of libopencv*.a is working for anybody with armv7. Also I am not sure what cmake buildoptions I should use, ie: what buildoptions were used to create the libs in the openframeworks repo?.

I get the same error on arm7, both on Cubieboard and on Beaglebone

You could give the libs that I compiled from the opencv source a whirl, see this pull request here:

Since I never got a reply about the compile-flags to use for the libs, I have sofar forgotten to make a formal pullrequest against the main repo.

edit: you can download the separate files here:

thanks a lot, I will try it

your lib seems to work for me too, thanks a lot

Hello!
I’m having problems compiling the opencv example on raspberryPi 2.
I’ve replaced the contents of addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l
with the recompiled files linked above by @fieldOfView. (just downloaded each one from github by clicking ‘browse files’ and swapped them out. Was there something else I should do?

Here are my errors:

/usr/bin/ld:…/…/…/addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_legacy.a: file format not recognized; treating as linker script
/usr/bin/ld:…/…/…/addons/ofxOpenCv/libs/opencv/lib/linuxarmv7l/libopencv_legacy.a:4: syntax error
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

Thanks for any help!!

Oh!

Here are the original errors before I swapped for the fieldOfVision compile.
Cheers!

…/…/…/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/apps/CANApps/opencvExample’
…/…/…/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:126: recipe for target ‘Release’ failed
make: *** [Release] Error 2

Awesome!

Recently got my Raspberry PI2 shipped and ran into the same errors when I tried my ofxCvPiCam addon.
Glad I didn’t have to recompile OpenCV from source on a Raspberry PI again. I’m guessing this will work on other armv7 boards like ODroid too.

Speaking of compiling, how long did it take @fieldOfView ?
In theory if RPI2 is ~6x times faster would’ve that meant about ~1.6 hours/2hours ?

Thanks for sharing the libraries and hoping they will make it into the official oF repo.

It’s been quite a while since I compiled the libs. I did not use a raspbarry pi but an Allwinner A20-based board. So it did not take too long.

Hello @fieldOfView it looks like the files you provide at https://github.com/fieldOfView/openFrameworks/commit/a1077f19ca7129cd7a5fbdea2dca1934875dcdc2 are the same as the ones in the current arm7 OF distro. I checked the sha1sums on the files to verify. What commands did you use to recompile the openCV deps?

Right now the only thing that isn’t working under examples/ after using this guide on a pi2 is the openCV stuff.

@plural: I am quite sure they are not the same; the filesizes don’t even match. It’s been too long ago to know the exact options I used; I’ll see what I can trace back when I have access to the board I compiled the libs on (the sources/configuration should still be there).

Shouldn’t it be possible to apt-get install opencv systemwide and use those libs instead of ones supplied with the openframeworks distro? Linux/ARMv7 is not my native OS/chip, so I’m not sure.

@fieldOfView yeah, i think i ended up checking out the wrong git branch. Sorry for the noise. I’m digging through the cmake config for openCV now to see if i can get that to work as well.

i pulled down openCV, ran the interactive cmake config with “cmake -i” and made sure to build static libs. That built just fine (it took a while). I copied those .a files into the proper location and the examples with openCV build just fine now.

For the time being if you are using a patched 0.8.4 release, you can download the version I compiled (which seems to work on raspberry pi 2 as well as other armv7 hardware):
http://files.fieldofview.com/temp/ofxopencv_armv7_libs.tar.gz

Going forward, openframeworks is going to use system-installed versions of the lib instead of libs that are in the openFrameworks repository:
https://github.com/openframeworks/openFrameworks/pull/3166