c++ - 生成文件 : error running 'make all'

标签 c++ c gcc compiler-construction

当我运行 make all 规则中指定的相同 gcc 命令时,我没有收到任何错误。但是当我运行 make all 时,我得到了一堆错误。为什么会这样?

生成文件:

all: program.c
      gcc -I$HOME/ffmpeg/include program.c -L$HOME/ffmpeg/lib -lswscale -lavdevice -lavfilter -lswscale -lswresample -lavformat -lavcodec -lavutil -lz -lm -lpthread -o program

运行 gcc 命令:

 (No error)

运行 make all:

gcc -IOME/ffmpeg/include program.c -LOME/ffmpeg/lib -lswscale -lavdevice -lavfilter -lswscale -lswresample -lavformat -lavcodec -lavutil -lz -lm -lpthread -o program
program.c:15:32: error: libavcodec/avcodec.h: No such file or directory
program.c:16:32: error: libswscale/swscale.h: No such file or directory
program.c:17:34: error: libavformat/avformat.h: No such file or directory
program.c:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
program.c:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
program.c:95: error: expected ')' before '*' token
program.c:128: error: expected ')' before '*' token
program.c:201: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
program.c: In function 'main':
program.c:253: error: 'AVFrame' undeclared (first use in this function)
program.c:253: error: (Each undeclared identifier is reported only once
program.c:253: error: for each function it appears in.)
program.c:253: error: 'loaded_image' undeclared (first use in this function)
program.c:255: error: 'img_copy' undeclared (first use in this function)
program.c:255: error: 'AV_PIX_FMT_RGB24' undeclared (first use in this function)
program.c:256: error: 'current_frame' undeclared (first use in this function)
make: *** [all] Error 1

最佳答案

$HOME 在您的 make 环境中扩展为 OME。如果你想让 shell 展开它,你需要转义它:

  gcc -I$$HOME/ffmpeg/include ...

你现在发生的事情是 make$H 扩展为空,然后按原样使用该行的其余部分。

关于c++ - 生成文件 : error running 'make all' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22518314/

相关文章:

c++ - 我如何使用 LDA 对信号进行分类

c++ - 如何避免在 linux 上使用系统标准 C/C++ 库?

c - gcc 上 C90 的静态断言

C++代码,只读变量不可赋值

c++ - Armadillo :将立方体 subview (管)转换为 vector

c - 通过 Julia 的 C 接口(interface)为 `*x` 赋值

c - 使用 gcc 4.8 构建时如何检测是否使用地址 sanitizer 构建?

c++ - 将字符串流传递给函数

c++ - pcap_lookupdev 总是返回 NULL

c - 为结构体数组内的结构体指针分配内存