我正在使用dranger的ffmpeg教程:
http://dranger.com/ffmpeg/tutorial01.html
我试图编译第一个教程。我使用自制软件下载了ffmpeg,但是教程中提供的编译命令不起作用:
gcc -o tutorial01 tutorial01.c -lavutil -lavformat -lavcodec -lz -lavutil -lm
根据我对SDL的经验,我创建了一个单独的文件,其中只包含一个ffmpeg头文件,并将编译命令更改为:
gcc main.c -I/usr/local/Cellar/ffmpeg/2.6.1/include
它实际上能够编译。但是当我使用这个命令尝试使用教程文件时:
gcc tutorial01.c -I/usr/local/Cellar/ffmpeg/2.6.1/include
我收到了这些错误:
Undefined symbols for architecture x86_64:
"_av_dump_format", referenced from:
_main in tutorial01-9cd32b.o
"_av_frame_alloc", referenced from:
_main in tutorial01-9cd32b.o
"_av_frame_free", referenced from:
_main in tutorial01-9cd32b.o
"_av_free", referenced from:
_main in tutorial01-9cd32b.o
"_av_free_packet", referenced from:
_main in tutorial01-9cd32b.o
"_av_malloc", referenced from:
_main in tutorial01-9cd32b.o
"_av_read_frame", referenced from:
_main in tutorial01-9cd32b.o
"_av_register_all", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_alloc_context3", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_close", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_copy_context", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_decode_video2", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_find_decoder", referenced from:
_main in tutorial01-9cd32b.o
"_avcodec_open2", referenced from:
_main in tutorial01-9cd32b.o
"_avformat_close_input", referenced from:
_main in tutorial01-9cd32b.o
"_avformat_find_stream_info", referenced from:
_main in tutorial01-9cd32b.o
"_avformat_open_input", referenced from:
_main in tutorial01-9cd32b.o
"_avpicture_fill", referenced from:
_main in tutorial01-9cd32b.o
"_avpicture_get_size", referenced from:
_main in tutorial01-9cd32b.o
"_sws_getContext", referenced from:
_main in tutorial01-9cd32b.o
"_sws_scale", referenced from:
_main in tutorial01-9cd32b.o
我想我必须在教程中添加额外的东西,所以我做了
gcc tutorial01.c -I/usr/local/Cellar/ffmpeg/2.6.1/include -lavutil -lavformat -lavcodec -lz -lavutil -lm
但后来我收到了这个错误
ld: library not found for -lavutil
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
我觉得目录/usr/local/Cellar/ffmpeg/2.6.1/lib
可能是相关的,它包含文件:
libavcodec.56.26.100.dylib libavresample.dylib
libavcodec.56.dylib libavutil.54.20.100.dylib
libavcodec.a libavutil.54.dylib
libavcodec.dylib libavutil.a
libavdevice.56.4.100.dylib libavutil.dylib
libavdevice.56.dylib libpostproc.53.3.100.dylib
libavdevice.a libpostproc.53.dylib
libavdevice.dylib libpostproc.a
libavfilter.5.11.102.dylib libpostproc.dylib
libavfilter.5.dylib libswresample.1.1.100.dylib
libavfilter.a libswresample.1.dylib
libavfilter.dylib libswresample.a
libavformat.56.25.101.dylib libswresample.dylib
libavformat.56.dylib libswscale.3.1.101.dylib
libavformat.a libswscale.3.dylib
libavformat.dylib libswscale.a
libavresample.2.1.0.dylib libswscale.dylib
libavresample.2.dylib pkgconfig
libavresample.a
我经常真的失去了尝试编译下载的库(我花了很长时间才能让SDL编译,当我终于开始工作时,我仍然没有完全理解为什么)。< / p>
如果有人能帮助我理解这些东西是如何工作的,并且特别帮助我编写第一个教程,我将非常感激。
感谢您的时间。
答案 0 :(得分:2)
ffmpeg似乎使用pkgconfig。所以也许你看看如何使用它。
http://people.freedesktop.org/~dbn/pkg-config-guide.html
简而言之:
cc `pkg-config --cflags --libs x` -o myapp myapp.c
是你必须添加到编译器调用的东西。其中x是库名(如ffmpeg)