mpenkov / ffmpeg-tutorial

A set of tutorials that demonstrates how to write a video player based on FFmpeg
http://www.ffmpeg.org/documentation.html
1.22k stars 395 forks source link

Linking step fails on vanilla Ubuntu Precise #2

Closed brianthelion closed 12 years ago

brianthelion commented 12 years ago
br@breach ~/ffmpeg-tutorial $ make
mkdir -p obj
mkdir -p bin
gcc -Wall -ggdb `pkg-config --cflags libavcodec libavformat libavutil libswscale sdl` -Wno-write-strings -Wno-unused -c tutorial01.c -o obj/tutorial01.o
gcc -Wall -ggdb `pkg-config --cflags libavcodec libavformat libavutil libswscale sdl` -Wno-write-strings -Wno-unused `pkg-config --cflags libavcodec libavformat libavutil libswscale sdl` `pkg-config --libs libavcodec libavformat libavutil libswscale sdl` -lm obj/tutorial01.o  -o bin/tutorial01.out
obj/tutorial01.o: In function `main':
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:69: undefined reference to `av_register_all'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:72: undefined reference to `avformat_open_input'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:76: undefined reference to `avformat_find_stream_info'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:80: undefined reference to `av_dump_format'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:96: undefined reference to `avcodec_find_decoder'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:102: undefined reference to `avcodec_open2'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:106: undefined reference to `avcodec_alloc_frame'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:109: undefined reference to `avcodec_alloc_frame'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:114: undefined reference to `avpicture_get_size'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:116: undefined reference to `av_malloc'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:118: undefined reference to `sws_getContext'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:136: undefined reference to `avpicture_fill'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:145: undefined reference to `avcodec_decode_video2'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:152: undefined reference to `sws_scale'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:170: undefined reference to `av_free_packet'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:141: undefined reference to `av_read_frame'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:174: undefined reference to `av_free'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:175: undefined reference to `av_free'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:178: undefined reference to `av_free'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:181: undefined reference to `avcodec_close'
/home/br/dev/cocktail/build/ffmpeg-tutorial/tutorial01.c:184: undefined reference to `avformat_close_input'
collect2: ld returned 1 exit status
make: *** [bin/tutorial01.out] Error 1

where

br@breach ~/ffmpeg-tutorial $ echo `pkg-config --cflags libavcodec libavformat libavutil libswscale sdl` && echo `pkg-config --libs libavcodec libavformat libavutil libswscale sdl`
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL
-lavcodec -lavformat -lavutil -lswscale -lSDL
mpenkov commented 12 years ago

Can you suggest a command-line that works on your system?

mpenkov commented 12 years ago

I managed to reproduce the error on my side after performing a system update. It sounds like the order of arguments to gcc was the problem here. I've updated the Makefile and resolved the problem.