马春杰杰 Exit Reader Mode

< builtin >: recipe for target ‘ImageIOpng.o’ failed

 

编译光流图color_flow打开程序的时候,出现错误:

$ make
g++  -O3 -W -Wall  -c -o Convert.o Convert.cpp
g++  -O3 -W -Wall  -c -o Convolve.o Convolve.cpp
g++  -O3 -W -Wall  -c -o Image.o Image.cpp
g++  -O3 -W -Wall  -c -o ImageIO.o ImageIO.cpp
ImageIO.cpp: In function ‘void ReadFileTGA(CByteImage&, const char*)’:
ImageIO.cpp:169:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
         if (h.cMapBits != 24)
         ^~
ImageIO.cpp:171:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
      int l = fileBytes * cMapSize;
      ^~~
ImageIO.cpp: In function ‘void ReadFilePGM(CByteImage&, const char*)’:
ImageIO.cpp:358:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (stream == 0)
     ^~
ImageIO.cpp:361:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  int width, height, nBands;
  ^~~
ImageIO.cpp: In function ‘void read_header(FILE*, const char*, char, char, int*, int*, int*, int)’:
ImageIO.cpp:334:25: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fp, "%d", width);
                         ^
ImageIO.cpp:336:26: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fp, "%d", height);
                          ^
ImageIO.cpp:339:27: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   fscanf(fp, "%d", nbands);
                           ^
g++  -O3 -W -Wall  -c -o ImageIOpng.o ImageIOpng.cpp
ImageIOpng.cpp:19:17: fatal error: png.h: No such file or directory
 #include "png.h"
                 ^
compilation terminated.
<builtin>: recipe for target 'ImageIOpng.o' failed
make: *** [ImageIOpng.o] Error 1

问题出现在环境上,主要是依赖包没有安装,使用以下命令安装即可:

Centos:

sudo yum install libpng-devel

Ubuntu:

sudo apt install libpng-dev

本文最后更新于2021年8月15日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!