Closed sumangalasomayaji closed 4 years ago
Hi! Thanks for using the guide, and bummer to see that errors occur. I've seen these errors before and I believe it has to do with libraries compiled with different GCC versions. Have you been able to solve in the mean time?
I am also seeing the exact same errors...
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libresolv.so.2: undefined reference to `__resolv_context_put@GLIBC_PRIVATE'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libresolv.so.2: undefined reference to `__resolv_context_get_override@GLIBC_PRIVATE'
/home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libgio-2.0.so.0: undefined reference to `fcntl64@GLIBC_2.28'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libresolv.so.2: undefined reference to `__resolv_context_get_preinit@GLIBC_PRIVATE'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libresolv.so.2: undefined reference to `__h_errno@GLIBC_PRIVATE'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libselinux.so.1: undefined reference to `fcntl@GLIBC_2.28'
../../lib/libopencv_videoio.so.3.2.0: undefined reference to `__pointer_chk_guard_local'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libmount.so.1: undefined reference to `getrandom@GLIBC_2.25'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libudev.so.1: undefined reference to `reallocarray@GLIBC_2.26'
/home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libbsd.so.0: undefined reference to `__explicit_bzero_chk@GLIBC_2.25'
/home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libresolv.so.2: undefined reference to `__resolv_context_get@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status
apps/visualisation/CMakeFiles/opencv_visualisation.dir/build.make:99: recipe for target 'bin/opencv_visualisation' failed
make[2]: *** [bin/opencv_visualisation] Error 1
CMakeFiles/Makefile2:5261: recipe for target 'apps/visualisation/CMakeFiles/opencv_visualisation.dir/all' failed
make[1]: *** [apps/visualisation/CMakeFiles/opencv_visualisation.dir/all] Error 2
I tried updating the version of gcc and g++ that's being used to cross compile to a linaro version: https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/arm-linux-gnueabihf/ (following suggestion from https://stackoverflow.com/a/40914810). Didn't solve the issue and spit out the exact same error.
Which Ubuntu version do you use?
And did you update the libc-references mentioned in https://github.com/HesselM/rpicross_notes/blob/master/06-xc-opencv.md#compilation step 3?
It might be the case the more files need to be changed as files might refer to the host libs instead of the arm-libs. Could you check the lib/arm-linux-gnueabihf
folder and if the references libresolv
, libselinux
etc are ok?
I made sure to update the libc reference and everything in my rootfs lib directory has been fixed in regards to all the symlinks and such. I believe the issue is a side affect of not setting the CMAKE_SYSROOT to the rootfs because of
Ideally, the CMAKE_SYSROOT command should be used to set to rootfs for a crosscompilation target. However, I did not succeed at setting the parameter properly and therefor use the sysroot located at...
but the libraries in the raspberry/tools sysroot are now outdated.
The version of glibc in the tools sysroot is 2.19 where the latest versions of opencv require 2.28...
I was able to get around this issue by sym-linking certain libraries to the ones in my rootfs and leaving everything else along, though this was tedious and required 6 symlinks:
So I was able to find the issue as to why compiling with CMAKE_SYSROOT
set to the rootfs wasn't working and it was because g++ was looking for some libraries in the root rootfs/lib
and rootfs/usr/lib
which was empty since everything is inside of the arm-linux-gnueabihf
folder.
But if you look at the raspberry pi tools, they have files symlinked into the base lib directories from the arm-linux-gnueabihf
folder. To fix the issues, I was able to symlink the files that were being expected to be present in the root lib dirs like so:
ln -sf /home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/crtn.o /home/connor/rpi/rootfs/usr/lib/crtn.o
...
ln -sf /home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/librt.so /home/connor/rpi/rootfs/usr/lib/librt.so
hm, interesting. So you eventually where able to use CMAKE_SYSROOT
?
I saw some patches in your fork with symlink creation with different names:
ln -sf /home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libsupc++.a /home/connor/rpi/rootfs/lib/aibsupc++.a
ln -sf /home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libthread_db-1.0.so /home/connor/rpi/rootfs/lib/arm-linux_db-1.0.so
ln -sf /home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libthread_db.so.1 /home/connor/rpi/rootfs/lib/arm-linad_db.so.1
ln -sf /home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libutil-2.28.so /home/connor/rpi/rootfs/lib/arm-lil-2.28.so
ln -sf /home/connor/rpi/rootfs/lib/arm-linux-gnueabihf/libutil.so.1 /home/connor/rpi/rootfs/lib/arbutil.so.1
Whats the idea behind renaming the symlinks?
On a side note: instead of using /home/connor/rpi/rootfs/
you could go for $TARGET_ROOT
as a base-path as that is a bit more user-friendly (in case you want to change the root).
So I was able to find the issue as to why compiling with
CMAKE_SYSROOT
set to the rootfs wasn't working and it was because g++ was looking for some libraries in the rootrootfs/lib
androotfs/usr/lib
which was empty since everything is inside of thearm-linux-gnueabihf
folder.But if you look at the raspberry pi tools, they have files symlinked into the base lib directories from the
arm-linux-gnueabihf
folder. To fix the issues, I was able to symlink the files that were being expected to be present in the root lib dirs like so:ln -sf /home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/crtn.o /home/connor/rpi/rootfs/usr/lib/crtn.o ... ln -sf /home/connor/rpi/rootfs/usr/lib/arm-linux-gnueabihf/librt.so /home/connor/rpi/rootfs/usr/lib/librt.so
I've fixed the sysroot issues. As such I'll close this issue.
First of all I thank you for the detailed write up.
We have followed the steps you mentioned, through 01-setup.md till 06-xc-opencv.md.
The output for cmake is
General configuration for OpenCV 3.2.0 ===================================== -- Version control: unknown
-- Extra modules: -- Location (extra): /home/pi/rpi/src/opencv_contrib-3.2.0/modules -- Version control (extra): unknown
-- Platform: -- Timestamp: 2018-04-26T11:58:06Z -- Host: Linux 4.4.0-121-generic x86_64 -- Target: Linux 1 arm -- CMake: 3.5.1 -- CMake generator: Unix Makefiles -- CMake build tool: /usr/bin/make -- Configuration: Release
-- C/C++: -- Built as dynamic libs?: YES -- C++ Compiler: /usr/bin/rpizero-g++ (ver 4.9.3) -- C++ flags (Release): -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -- C++ flags (Debug): -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG -- C Compiler: /usr/bin/rpizero-gcc -- C flags (Release): -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG -- C flags (Debug): -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -isystem /home/pi/rpi/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/pi/rpi/rootfs/usr/include -isystem /home/pi/rpi/rootfs/usr/local/include -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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG -- Linker flags (Release): -- Linker flags (Debug): -- ccache: NO -- Precompiled headers: NO -- Extra dependencies: gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 fontconfig freetype gthread-2.0 gstbase-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 dc1394 dl m pthread rt -- 3rdparty dependencies: zlib libjpeg libwebp libpng libtiff libjasper IlmImf libprotobuf tegra_hal
-- OpenCV modules: -- To be built: core flann imgproc ml photo reg surface_matching video dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python3 -- Disabled: world contrib_world -- Disabled by dependency: - -- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 ts viz cnn_3dobj cvv hdf matlab sfm
-- GUI: -- QT: NO -- GTK+ 2.x: YES (ver 2.24.31) -- GThread : YES (ver 2.50.3) -- GtkGlExt: NO -- OpenGL support: NO -- VTK support: NO
-- Media I/O: -- ZLib: zlib (ver 1.2.8) -- JPEG: libjpeg (ver 90) -- WEBP: build (ver 0.3.1) -- PNG: build (ver 1.6.24) -- TIFF: build (ver 42 - 4.0.2) -- JPEG 2000: build (ver 1.900.1) -- OpenEXR: build (ver 1.7.1) -- GDAL: NO -- GDCM: NO
-- Video I/O: -- DC1394 1.x: NO -- DC1394 2.x: YES (ver 2.2.5) -- FFMPEG: NO -- avcodec: YES (ver 57.64.101) -- avformat: YES (ver 57.56.101) -- avutil: YES (ver 55.34.101) -- swscale: YES (ver 4.2.100) -- avresample: NO -- GStreamer: NO -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- OpenNI2: NO -- PvAPI: NO -- GigEVisionSDK: NO -- Aravis SDK: NO -- UniCap: NO -- UniCap ucil: NO -- V4L/V4L2: NO/YES -- XIMEA: NO -- Xine: NO -- gPhoto2: NO
-- Parallel framework: pthreads
-- Other third-party libraries: -- Use IPP: NO -- Use VA: NO -- Use Intel VA-API/OpenCL: NO -- Use Lapack: NO -- Use Eigen: NO -- Use Cuda: NO -- Use OpenCL: YES -- Use OpenVX: NO -- Use custom HAL: YES (carotene (ver 0.0.1))
-- OpenCL:
-- Include path: /home/pi/rpi/src/opencv-3.2.0/3rdparty/include/opencl/1.2
-- Use AMDFFT: NO
-- Use AMDBLAS: NO
-- Python 2: -- Interpreter: NO
-- Python 3: -- Interpreter: /usr/bin/python3 (ver 3.5.2) -- Libraries: /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3) -- numpy: /home/pi/rpi/rootfs/usr/lib/python3/dist-packages/numpy/core/include (ver undefined - cannot be probed because of the cross-compilation) -- packages path: /home/pi/rpi/rootfs/usr/local/lib/python3.5/site-packages
-- Python (for build): /usr/bin/python3
-- Java: -- ant: NO -- JNI: NO -- Java wrappers: NO -- Java tests: NO
-- Matlab: Matlab not found or implicitly disabled
-- Documentation: -- Doxygen: NO
-- Tests and samples: -- Tests: NO -- Performance tests: NO -- C/C++ Examples: NO
-- Install path: /home/pi/rpi/rootfs/usr
-- cvconfig.h is in: /home/pi/rpi/build/opencv
-- -- Configuring done -- Generating done -- Build files have been written to: /home/pi/rpi/build/opencv
We see the following error, for make install.
It would be great to hear from you!