When I run the same gcc command specified in my make all rule, I get no error. But when I run make all, I get a bunch of errors. Why is this happening?
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
Running the gcc command:
(No error)
Running 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
expands as OME
in your make
environment. If you want the shell to expand it, you need to escape it:
gcc -I$$HOME/ffmpeg/include ...
What's happening to you now is that make
is expanding $H
to nothing, then using the rest of the line as-is.