Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conda-build of official AnacondaRecipes/opencv-feedstock fails looking for libpng.h

I have downloaded the official conda recipe of opencv in AnacondaRecipes.

I have tried to build this package executing:

conda-build recipe -c conda-forge

I am getting the following error when the recipe compiles opencv, when doing [ 72%] Built target opencv_dnn . The error is the following:

[ 67%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_png.cpp.o
/opt/conda/conda-bld/opencv_1521187259162/work/modules/imgcodecs/src/grfmt_png.cpp:62:10: fatal error: libpng/png.h: No such file or directory
 #include <libpng/png.h>
          ^~~~~~~~~~~~~~
compilation terminated.
modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/build.make:326: recipe for target 'modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_png.cpp.o' failed
make[2]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_png.cpp.o] Error 1
CMakeFiles/Makefile2:4645: recipe for target 'modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all' failed
make[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Lookin in the $PREFIX directory, there is not libpng folder, only a libpng16 folder:

/opt/conda/conda-bld/opencv_1521187259162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/include/

I suspect it must be something related to how conda-build manages the path environment, but I do not have any clue of how to solve it.

Environment: conda 4.4.11, OS: Ubuntu 16.04.

UPDATE 23/03/2018

I have also tried:

  • add libpng/png.h to the location pointed by the $PREFIX directory.
  • add /usr/include to the $PATH

No success in either case.

UPDATE 04/03/2018

  • libpng-dev is installed in the environment.

UPDATE 09/04/2018

  • Docker recipe to reproduce environment

UPDATE 12/04/2018

  • Docker recipe using miniconda3 and installing conda in /usr/local/conda instead of /opt/conda
like image 448
jruizaranguren Avatar asked Mar 22 '18 16:03

jruizaranguren


1 Answers

So the issue you have here is that you need the libpng-dev library installed on your OS. Since you mentioned you're operating in a Ubuntu env, you can simply type

sudo apt-get install libpng-dev

Hope this resolves the issue!

UPDATE

Why didn't you try to install opencv with the commands provided in the link:

conda config --add channels conda-forge
conda install opencv
like image 81
Haris Nadeem Avatar answered Oct 15 '22 16:10

Haris Nadeem