CFLAGS in Makefile

将$(CFLAGS)放在前面编译会有错误

 

$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

 

output-example.o: In function `add_audio_stream':

output-example.c:(.text+0x15): undefined reference to `av_new_stream'

output-example.o: In function `open_audio':

output-example.c:(.text+0xdb): undefined reference to `avcodec_find_encoder'

output-example.c:(.text+0x12a): undefined reference to `avcodec_open'

output-example.c:(.text+0x1d1): undefined reference to `av_malloc'

output-example.c:(.text+0x248): undefined reference to `av_malloc'

放到后面就可以编译成功

 

$(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS)

 

 

原因是CFLAGS有"-L"和"-l"链接库文件, 这些参数必须放在"-o xxx"之后.

你可能感兴趣的:(Stream,function,makefile,reference,audio)