opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

build opencv in termux, when build opencv_waldboost_detector error in undefined reference to '__android_log_print'

Open wahyubram82 opened this issue 5 years ago • 8 comments

i cannot build opencv in termux error when reach time to 'waldboost' part. i copy the result with make VERBOSE=1, hope someone can told me how to fix it

make[2]: Entering directory '/data/data/com.termux/files/home/opencv/build'
[ 82%] Linking CXX executable ../../../../bin/opencv_waldboost_detector                                       cd /data/data/com.termux/files/home/opencv/build/modules/xobjdetect/tools/waldboost_detector && /data/data/com.termux/files/usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_waldboost_detector.dir/link.txt --verbose=1
/data/data/com.termux/files/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG    -Wl,--gc-sections   CMakeFiles/opencv_waldboost_detector.dir/waldboost_detector.cpp.o  -o ../../../../bin/opencv_waldboost_detector -Wl,-rpath,::::::::::::::::::::::::::::::::::::: ../../../../lib/libopencv_core.a ../../../../lib/libopencv_imgproc.a ../../../../lib/libopencv_imgcodecs.a ../../../../lib/libopencv_videoio.a ../../../../lib/libopencv_highgui.a ../../../../lib/libopencv_xobjdetect.a ../../../../lib/libopencv_videoio.a /data/data/com.termux/files/usr/lib/libavcodec.so /data/data/com.termux/files/usr/lib/libavformat.so /data/data/com.termux/files/usr/lib/libavutil.so /data/data/com.termux/files/usr/lib/libswscale.so /data/data/com.termux/files/usr/lib/libgthread-2.0.so /data/data/com.termux/files/usr/lib/libglib-2.0.so ../../../../lib/libopencv_imgcodecs.a /data/data/com.termux/files/usr/lib/libjpeg.so ../../../../3rdparty/lib/liblibwebp.a /data/data/com.termux/files/usr/lib/libpng.so /data/data/com.termux/files/usr/lib/libtiff.so ../../../../3rdparty/lib/liblibjasper.a ../../../../3rdparty/lib/libIlmImf.a ../../../../lib/libopencv_objdetect.a ../../../../lib/libopencv_calib3d.a ../../../../lib/libopencv_features2d.a ../../../../lib/libopencv_imgproc.a ../../../../lib/libopencv_flann.a ../../../../lib/libopencv_core.a /data/data/com.termux/files/usr/lib/libz.so /data/data/com.termux/files/usr/lib/libopenblas.so -ldl -lm -lpthread -lrt ../../../../3rdparty/lib/libtegra_hal.a ../../../../3rdparty/lib/libquirc.a
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: ../../../../lib/libopencv_core.a(system.cpp.o): in function `cv::error(cv::Exception const&)':                                                                system.cpp:(.text._ZN2cv5errorERKNS_9ExceptionE+0x1ac): undefined reference to `__android_log_print'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: ../../../../lib/libopencv_core.a(logger.cpp.o): in function `cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LogLevel, char const*)':       logger.cpp:(.text._ZN2cv5utils7logging8internal15writeLogMessageENS1_8LogLevelEPKc+0x4ec): undefined reference to `__android_log_print'                                                                                     clang-8: error: linker command failed with exit code 1 (use -v to see invocation)                             make[2]: *** [modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/build.make:114: bin/opencv_waldboost_detector] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/opencv/build'
make[1]: *** [CMakeFiles/Makefile2:4661: modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/all] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/opencv/build'
make: *** [Makefile:163: all] Error 2

wahyubram82 avatar Jun 29 '19 18:06 wahyubram82

if you don need that, then disable it here (comment or remove.


Unfortunately, we don't have builds (or environment setup) with mentioned configuration so we can't help with problem investigation.

Anyway, we can take a look on the clear reason of the problem and suggest some fix/workaround. But please ensure that you are working with fresh code base (use latest releases).

alalek avatar Jun 29 '19 19:06 alalek

for a temporary, i comment the CMakefile.txt then the make process continue until show another error. this is the result with VERBOSE=1

make[2]: Entering directory '/data/data/com.termux/files/home/opencv/build' [100%] Linking CXX executable ../../bin/opencv_annotation cd /data/data/com.termux/files/home/opencv/build/apps/annotation && /data/data/com.termux/files/usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_annotation.dir/link.txt --verbose=1 /data/data/com.termux/files/usr/bin/c++ -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -Wl,--gc-sections CMakeFiles/opencv_annotation.dir/opencv_annotation.cpp.o -o ../../bin/opencv_annotation -Wl,-rpath,::::::::::::::::::::::::::::::::::::: -ldl -lm -lpthread -lrt ../../lib/libopencv_core.a ../../lib/libopencv_highgui.a ../../lib/libopencv_imgproc.a ../../lib/libopencv_imgcodecs.a ../../lib/libopencv_videoio.a ../../lib/libopencv_imgcodecs.a ../../lib/libopencv_imgproc.a ../../lib/libopencv_core.a -ldl -lm -lpthread -lrt /data/data/com.termux/files/usr/lib/libopenblas.so /data/data/com.termux/files/usr/lib/libjpeg.so /data/data/com.termux/files/usr/lib/libwebp.so /data/data/com.termux/files/usr/lib/libpng.so /data/data/com.termux/files/usr/lib/libtiff.so ../../3rdparty/lib/liblibjasper.a ../../3rdparty/lib/libIlmImf.a /data/data/com.termux/files/usr/lib/libz.so /data/data/com.termux/files/usr/lib/libavcodec.so /data/data/com.termux/files/usr/lib/libavformat.so /data/data/com.termux/files/usr/lib/libavutil.so /data/data/com.termux/files/usr/lib/libswscale.so ../../3rdparty/lib/libtegra_hal.a /data/data/com.termux/files/usr/lib/libgthread-2.0.so /data/data/com.termux/files/usr/lib/libglib-2.0.so /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: ../../lib/libopencv_core.a(system.cpp.o): in function cv::error(cv::Exception const&)': system.cpp:(.text._ZN2cv5errorERKNS_9ExceptionE+0x1ac): undefined reference to __android_log_print' /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: ../../lib/libopencv_core.a(logger.cpp.o): in function cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LogLevel, char const*)': logger.cpp:(.text._ZN2cv5utils7logging8internal15writeLogMessageENS1_8LogLevelEPKc+0x4ec): undefined reference to __android_log_print' clang-8: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:107: bin/opencv_annotation] Error 1 make[2]: Leaving directory '/data/data/com.termux/files/home/opencv/build' make[1]: *** [CMakeFiles/Makefile2:5921: apps/annotation/CMakeFiles/opencv_annotation.dir/all] Error 2 make[1]: Leaving directory '/data/data/com.termux/files/home/opencv/build' make: *** [Makefile:163: all] Error 2

I think it's a bit different from waldboost, need another help....

wahyubram82 avatar Jun 29 '19 20:06 wahyubram82

cmake -DBUILD_opencv_apps=OFF ... (should be OFF for Android builds by default).

We have never tried to build Android binaries on Android directly. This mode is just unsupported. So We have no idea how many issues you will see during next steps. Probably you should add -DANDROID=ON too.

Attach your CMakeCache.txt / CmakeVars.txt to initial post, may be community may help. Also put link on used tutorial if any.


BTW, In general, changing of CMake options requires clean CMake's cache (clean build directory) to avoid undefined behavior from messing with previous CMake calls.

alalek avatar Jun 29 '19 20:06 alalek

sorry for late responses, it's too late last night. it's the latest source code that i use.

i use android on samsung tab S5e.

i install termux and python (automaticly installed python version 3.7.3, when apt install python) i download necessary dependencies.

like build_essential, tiff, jpeg library, etc, like build in linux, because i think termux is linux shell. then download the latest opencv build it.

btw, if i install anlinux on termux, i can install opencv without problem, but difficult to access the camera of my tablet. so my plan is install the opencv stright to termux to make easier acces camera with termux-am.

ok, back to the problem, this is the command i use with cmake. LDFLAGS=" -llog -lpython3" cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$PREFIX -D INSTALL_PYTHON_EXAMPLES=OFF -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=/data/data/com.termux/files/home/opencv_contrib/modules -D BUILD_opencv_python3=on -D BUILD_opencv_python2=off -D BUILD_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE:BOOL=ON -D WITH_TEST=OFF -D BUILD_PERF_TESTS=OFF -D WITH_PERF_TEST=OFF -D BUILD_TESTS=OFF -D WITH_LAPACK=OFF -DBUILD_opencv_apps=OFF -D ANDROID=OFF -D WITH1394=OFF -D WITH_VTK=OFF -D BUILD_ANDROID_EXAMPLES=OFF -D BUILD_ANDROID_PROJECTS=OFF -D WITH_CPUFEATURES=OFF -D ENABLE_NEON=ON -D ENABLE_VFPV3= ON -D INSTALL_PYTHON_EXAMPLES=OFF ..

already try with option: -D WITH_CPUFEATURES=ON

the clue is i should have libcpufeatures.so on my system but base on this i can build it stright to opencv. but still don't got any idea to do it.

the last error code:

make[2]: Entering directory '/data/data/com.termux/files/home/opencv/build'                         
[100%] Linking CXX shared module ../../lib/python3/cv2.cpython-37m.so                                
cd /data/data/com.termux/files/home/opencv/build/modules/python3 && /data/data/com.termux/files/usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_python3.dir/link.txt --verbose=1                     
/data/data/com.termux/files/usr/bin/c++ -fPIC    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -Wno-unused-function -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-unused-private-field -Wno-undef -O3 -DNDEBUG  -DNDEBUG  -Wl,--exclude-libs=ALL -shared  -o ../../lib/python3/cv2.cpython-37m.so CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o -Wl,-rpath,::::::::::::::::::::::::::::::::::::: ../../lib/libopencv_core.a ../../lib/libopencv_flann.a ../../lib/libopencv_imgproc.a ../../lib/libopencv_ml.a ../../lib/libopencv_phase_unwrapping.a ../../lib/libopencv_photo.a ../../lib/libopencv_plot.a ../../lib/libopencv_quality.a ../../lib/libopencv_reg.a ../../lib/libopencv_surface_matching.a ../../lib/libopencv_xphoto.a ../../lib/libopencv_dnn.a ../../lib/libopencv_features2d.a ../../lib/libopencv_freetype.a ../../lib/libopencv_fuzzy.a ../../lib/libopencv_hfs.a ../../lib/libopencv_img_hash.a ../../lib/libopencv_imgcodecs.a ../../lib/libopencv_line_descriptor.a ../../lib/libopencv_saliency.a ../../lib/libopencv_videoio.a ../../lib/libopencv_calib3d.a ../../lib/libopencv_highgui.a ../../lib/libopencv_objdetect.a ../../lib/libopencv_rgbd.a ../../lib/libopencv_shape.a ../../lib/libopencv_structured_light.a ../../lib/libopencv_text.a ../../lib/libopencv_video.a ../../lib/libopencv_videostab.a ../../lib/libopencv_xfeatures2d.a ../../lib/libopencv_ximgproc.a ../../lib/libopencv_xobjdetect.a ../../lib/libopencv_aruco.a ../../lib/libopencv_bgsegm.a ../../lib/libopencv_bioinspired.a ../../lib/libopencv_ccalib.a ../../lib/libopencv_datasets.a ../../lib/libopencv_dpm.a ../../lib/libopencv_face.a ../../lib/libopencv_optflow.a ../../lib/libopencv_sfm.a ../../lib/libopencv_stitching.a ../../lib/libopencv_superres.a ../../lib/libopencv_tracking.a /data/data/com.termux/files/usr/lib/libfreetype.so /data/data/com.termux/files/usr/lib/libharfbuzz.so ../../lib/libopencv_phase_unwrapping.a ../../lib/libopencv_photo.a ../../lib/libopencv_objdetect.a ../../3rdparty/lib/libquirc.a ../../lib/libcorrespondence.a ../../lib/libmultiview.a ../../lib/libnumeric.a /data/data/com.termux/files/usr/lib/libglog.so /data/data/com.termux/files/usr/lib/libgflags.so ../../lib/libopencv_xfeatures2d.a ../../lib/libopencv_shape.a ../../lib/libopencv_optflow.a ../../lib/libopencv_ximgproc.a ../../lib/libopencv_plot.a ../../lib/libopencv_video.a ../../lib/libopencv_calib3d.a ../../lib/libopencv_datasets.a ../../lib/libopencv_text.a ../../lib/libopencv_ml.a ../../lib/libopencv_dnn.a ../../3rdparty/lib/liblibprotobuf.a ../../lib/libopencv_features2d.a ../../lib/libopencv_flann.a ../../lib/libopencv_highgui.a ../../lib/libopencv_videoio.a ../../lib/libopencv_imgcodecs.a ../../lib/libopencv_imgproc.a ../../lib/libopencv_core.a /data/data/com.termux/files/usr/lib/libopenblas.so -llibcpufeatures /data/data/com.termux/files/usr/lib/libjpeg.so /data/data/com.termux/files/usr/lib/libwebp.so /data/data/com.termux/files/usr/lib/libpng.so /data/data/com.termux/files/usr/lib/libtiff.so ../../3rdparty/lib/liblibjasper.a ../../3rdparty/lib/libIlmImf.a /data/data/com.termux/files/usr/lib/libz.so /data/data/com.termux/files/usr/lib/libavcodec.so /data/data/com.termux/files/usr/lib/libavformat.so /data/data/com.termux/files/usr/lib/libavutil.so /data/data/com.termux/files/usr/lib/libswscale.so /data/data/com.termux/files/usr/lib/libgthread-2.0.so /data/data/com.termux/files/usr/lib/libglib-2.0.so -ldl -lm -lpthread -lrt ../../3rdparty/lib/libtegra_hal.a    /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -llibcpufeatures           
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)                    
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:174: lib/python3/cv2.cpython-37m.so] Error 1                                                                                       
make[2]: Leaving directory '/data/data/com.termux/files/home/opencv/build'                           
make[1]: *** [CMakeFiles/Makefile2:5796: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2  make[1]: Leaving directory '/data/data/com.termux/files/home/opencv/build'                           
make: *** [Makefile:163: all] Error 2`

it already reach 100% process...just a litle bit more, it will installed on termux

i think in the future, coding in linux on android device will be more popular. so i try to start it from now

wahyubram82 avatar Jun 30 '19 17:06 wahyubram82

Screenshot_2021-12-27-01-32-08-425_com.termux.jpg

if someone still interested I have successfully build it and install it

ixiDev avatar Dec 27 '21 01:12 ixiDev

Screenshot_2021-12-27-01-32-08-425_com.termux.jpg

if someone still interested I have successfully build it and install it

how did you installed it?

lukasloetkolben avatar Mar 09 '22 19:03 lukasloetkolben

Screenshot_2021-12-27-01-32-08-425_com.termux.jpg

if someone still interested I have successfully build it and install it

Please let know your cmake command.

thanks,

ravirathore avatar May 07 '22 12:05 ravirathore

@ravirathore just run
make install

Then go to any cmake project and you can use cmake command find_library(OpenCV)

ixiDev avatar Jul 29 '22 20:07 ixiDev