This question already has an answer here:
After updating my ubuntu OS from 14.04 to 16.04, I installed the ffmpeg library using the following configurations:
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-nonfree
PATH="$HOME/bin:$PATH" make
make install
It seemed to me the installation process was ok. After that, I tried to compile my own C source code with the following Makefile:
EDITTED(adding -lva-drm -lva-x11 at line 10)
FFMPEG_LIBS= libavdevice \
libavformat \
libavfilter \
libavcodec \
libswresample \
libswscale \
libavutil \
TARGET = video_analysis
LIBS = -lva -lX11 -lvdpau -lm -lva-drm -lva-x11
CC = gcc
CFLAGS += -O2 -g -O0
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
.PHONY: default all clean
default: $(TARGET)
all: default
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
HEADERS = $(wildcard *.h)
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(LDLIBS) $(LIBS) -o $@
clean:
-rm -f *.o
-rm -f $(TARGET)
However, my compiler complained the following errors:
/root/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_create':
/home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:896: undefined reference to `vaGetDisplay'
/home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:917: undefined reference to `vaGetDisplayDRM'
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'video_analysis' failed
make: *** [video_analysis] Error 1
My question is: in which library do 'vaGetDisplay' and `vaGetDisplayDRM' exist? It's for sure that libva functions properly. I have no clue how to fix the bugs...Thank you in advance!
after adding -lva-drm and -lva-x11 into Makefile, my compiler complains no error any more :-)
I got the exact same problem when I was trying to compile the latest ffmpeg source code examples. (2016-08-25)
When I have done compiling ffmpeg source, (all dependencies good), then I go to dir:
do:
and as instructed as README:
I got the C files compiled to .o files but cannot get linked. Same error output as:
I checked your solution here and discovered that although ffmpeg team are using
pkg-config
tool to config, but in the end it is agcc
command line to compile. (see the seconde line of code snippet above)All the flags below shall be moved to the end of
gcc
command line just before the-o
option:-lX11 -lm -lvdpau -lva -lva-drm -lva-x11
So instead of compiling with the next command line:(the command is long, scroll to right to see full)
I move the flags to the right side end and compile with:(the command is long, scroll to right to see full)
And all the compile errors are gone~! I think this is a common error when we compile other examples, or our own projects.