I followed this link (https://medium.com/analytics-vidhya/how-to-install-opencv-for-visual-studio-code-using-ubuntu-os-9398b2f32d53) to install opencv and I was able to execute it all the way till make -j4
step. At 99%, I get the following error
[ 99%] Built target opencv_annotation
[ 99%] Built target opencv_visualisation
[ 99%] Built target opencv_interactive-calibration
[ 99%] Linking CXX executable ../../bin/opencv_version
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: warning: libz.so.1, needed by ../../lib/libopencv_core.so.4.5.4, not found (try using -rpath or -rpath-link)
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzeof'
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzrewind'
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzopen'
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzclose'
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzgets'
/home/username/miniconda3/envs/ros/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to `gzputs'
collect2: error: ld returned 1 exit status
make[2]: *** [apps/version/CMakeFiles/opencv_version.dir/build.make:87: bin/opencv_version] Error 1
make[1]: *** [CMakeFiles/Makefile2:3626: apps/version/CMakeFiles/opencv_version.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
From what I understand, GCC is unable to find a shared library, libz.so.1
So in order to solve this issue I think I have to first locate where the said shared object file is and then let GCC know where to find it to complete the build and I don't know how to do it. (I may be wrong, apologies in advance, I'm a linux noob)
I tried
ldconfig -v | grep libz.so.1
which returns
username@Inspiron-7591:~/opencv/build(master)$ ldconfig -v | grep libz.so.1
/sbin/ldconfig.real: Can't stat opt/cubemos/skeleton_tracking/lib: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/local/lib/i386-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/lib/i386-linux-gnu' given more than once
/sbin/ldconfig.real: Can't stat /usr/local/lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib32' given more than once
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib' given more than once
/sbin/ldconfig.real: /lib/i386-linux-gnu/ld-2.31.so is the dynamic linker, ignoring
libz.so.1 -> libz.so.1.2.11
/sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-2.31.so is the dynamic linker, ignoring
libz.so.1 -> libz.so.1.2.11
/sbin/ldconfig.real: /lib32/ld-2.31.so is the dynamic linker, ignoring
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
libz.so.1 -> libz.so.1.2.11
I don't know what the above output is supposed to mean
I've also tried some of the following solutions that I could find but nothing seems to help.
I even tried giving sudo privileges to the make -j4
step but no luck
Note: I had recently installed ROS in a conda environment named "ros" and gcc is located inside of it.
I've been procrastinating for the past week because of this error and I finally decided to courage up and post it here. Any help is very much appreciated! Thanks in advance.