Error building from Linux tutorial

I was trying to follow the Liunx instructions here: OpenCV: Installation in Linux, but in the build stage I get the following error:

[ 22%] Linking CXX shared library ../../lib/libopencv_imgcodecs.so
CMakeFiles/opencv_imgcodecs.dir/src/grfmt_jpeg.cpp.o: In function `cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x6db): undefined reference to `jpeg_default_qtables'
CMakeFiles/opencv_imgcodecs.dir/src/grfmt_png.cpp.o: In function `cv::PngDecoder::readData(cv::Mat&)':
grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x3cb): undefined reference to `png_get_eXIf_1'
grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x491): undefined reference to `png_get_eXIf_1'
/usr/bin/ld: link errors found, deleting executable `../../lib/libopencv_imgcodecs.so.4.7.0'
/usr/bin/sha1sum: ../../lib/libopencv_imgcodecs.so.4.7.0: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [lib/libopencv_imgcodecs.so.4.7.0] Error 1
gmake[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
gmake: *** [all] Error 2

Do you have any suggestions? I tried to modify LD_LIBRARY_PATH to point to libpng.so, but this didn’t help.

looks like there’s an unexpected png version installed on your box. try to use the 3rd party version, that comes with the opencv src code:

cmake -DBUILD_PNG=ON ....

(so it won’t rely on your system’s libpng anymore)

Thanks, I did the same for JPEG and TIFF:
cmake -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON -DBUILD_TIFF=ON …/opencv-master
It looks like it helped, but now I’m stuck with a different error:

[ 72%] Linking CXX executable ../../bin/opencv_test_highgui
/usr/lib64/libfontconfig.so: undefined reference to `uuid_parse@UUID_1.0'
/usr/lib64/libfontconfig.so: undefined reference to `uuid_generate_random@UUID_1.0'
/usr/lib64/libfontconfig.so: undefined reference to `uuid_unparse@UUID_1.0'
/usr/lib64/libfontconfig.so: undefined reference to `uuid_copy@UUID_1.0'
/usr/bin/ld: link errors found, deleting executable `../../bin/opencv_test_highgui'
/usr/bin/sha1sum: ../../bin/opencv_test_highgui: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [bin/opencv_test_highgui] Error 1
gmake[1]: *** [modules/highgui/CMakeFiles/opencv_test_highgui.dir/all] Error 2
gmake: *** [all] Error 2

I’m working on a remote server.

hmm do you really need any gui there ?

also, just curious, do you have root access on that box ?
(more info on that server, please !)

how do you plan to use it, c++ dev ? python ?

if you run your program on a remote server, you will not get any GUI on your local computer from that program.

the truth is that yes there are ways but it’s a bad idea and “no” is the answer that doesn’t complicate your situation further.