简体   繁体   中英

How to properly link ffmpeg project in eclipse linux

I have a little test project on linux eclipse using ffmpeg. It is oke to make it using command line

g++ -o m_vector -I/usr/include -I/usr/local/include m_vector.cpp -lavformat -lavcodec -lavutil -lm -lz -lva -lpthread

but in eclipse while linking i get a big list of errors

/home/user/projects/ffmpeg/libavcodec/internal.h:194: undefined reference to `av_rescale_q'
/usr/local/lib/libavcodec.a(mpegvideo.o): In function `update_picture_tables':
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:663: undefined reference to `av_buffer_unref'
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:663: undefined reference to `av_buffer_ref'
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:664: undefined reference to `av_buffer_unref'
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:664: undefined reference to `av_buffer_ref'
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:665: undefined reference to `av_buffer_unref'
/home/user/projects/ffmpeg/libavcodec/mpegvideo.c:665: undefined reference to `av_buffer_ref'

and so on

I've aded the needed libs in project and i use "extern c". My project knows also about needed includes. Digging internet did not give the answer.

Swap the order of the libraries you're linking to, one depends on the other. The one that is depended on the most must be last, in this case libavutil.

The libraries will be searched in path_to_gcc/usr/lib. Hopefully you bmay not having the libraries there.Add -L$path-to-libraries

Ubuntu different Windows OS.
Ubuntu sort lib, so you can add lib like this:
-lavdevice -lavformat -lavcodec -lavutil -lswscale -lavfilter -lpthread -lz -lm -lswresample
After add finish. If you have error: undefined reference to vaCreateBuffer... then you should rebuild ffmpeg and disable -lva lib.
Example: You build in: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
Replace lines PATH to:
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" \\
--disable-vaapi
I don't build libx264, libx265, libfdk-aac..... b/c I don't need. If you need, you can build.
Line code: --disable-vaapi is disable -lva lib.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM