I would like to create my own project using FFMPEG to build a player, but creating a new file to include ffmpeg library seems not easy. I have configure the ffmpeg and make build.
./configure
./make
The ffmpeg hello world program (myffmpeg.c):
#include <libavformat/avformat.h> int main(int argc, char *argv[]) { av_register_all(); return 0; } but it shows
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
Undefined symbols for architecture x86_64:
"av_register_all()", referenced from:
_main in myffmpeg-61ec1b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation
When I try to link the allformats.o file, which has av_register_all function inside. I got:
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated Undefined symbols for architecture x86_64: "_av_register_input_format", referenced from: _register_all in allformats.o "_av_register_output_format", referenced from: _register_all in allformats.o "_avcodec_register_all", referenced from: _register_all in allformats.o "_ff_a64_muxer", referenced from: _register_all in allformats.o
...
"_ff_yuv4mpegpipe_muxer", referenced from: _register_all in allformats.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
It should be my bad Makefile knowledge, could anyone give me some hint on how to call ffmpeg library functions? Or even how to modify the Makefile to build my own program? Thanks!
*Update: It could be my compiling command problem, is it the way to compile?
g++ myffmpeg.c
doc/examples. Just wrap the headers like in the answer below.