jam*_*e_y 1 c c++ compiler-construction gcc
当我运行make all rule中指定的相同gcc命令时,我没有收到任何错误.但是当我运行make all时,我会遇到一堆错误.为什么会这样?
Makefile文件:
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
Run Code Online (Sandbox Code Playgroud)
运行gcc命令:
(No error)
Run Code Online (Sandbox Code Playgroud)
跑步全部:
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
Run Code Online (Sandbox Code Playgroud)
$HOME像OME在您的make环境中一样扩展.如果你想让shell扩展它,你需要转义它:
gcc -I$$HOME/ffmpeg/include ...
Run Code Online (Sandbox Code Playgroud)
你现在发生的事情是,它make正在扩展$H到什么,然后按原样使用其余部分.