我已经构建了一个引用FFMPEG
库的共享库。我很难将最终的申请链接起来。我已经摆弄了几个小时的图书馆订单,但没有快乐。
g++ -o testVideoTranscode testVideoTranscode.o /usr/lib/libstdc++.so.6 -L../../../lib3p -lavutil -lswresample -lavcodec -L../../../lib -ldvsutils -ldvscfg -ldvstc -lstdc++ -lmch264dec -lfreeimage -lpthread
../../../lib/libdvstc.so: undefined reference to `sws_getContext(int, int, AVPixelFormat, int, int, AVPixelFormat, int, SwsFilter*, SwsFilter*, double const*)'
../../../lib/libdvstc.so: undefined reference to `av_frame_alloc()'
../../../lib/libdvstc.so: undefined reference to `avcodec_close(AVCodecContext*)'
etc etc
例如,一个缺少的符号av_frame_alloc()
正确地位于ibavutil.so
库中(尽管位于非标准位置):
nm -D ../../../lib3p/libavutil.so | grep av_frame_alloc
00021360 T av_frame_alloc
我的库libdvstc.so
正确显示了对符号和文件的引用:
nm -D --demangle ../../../lib/libdvstc.so | grep av_frame_alloc
U av_frame_alloc()
ldd ../../../lib/libdvstc.so
linux-gate.so.1 => (0xb77c3000)
libavutil.so.55 => /mnt/swdevel/DVStor/source_build/lib3p/libavutil.so.55 (0xb772f000)
libswresample.so.2 => /mnt/swdevel/DVStor/source_build/lib3p/libswresample.so.2 (0xb7714000)
libavcodec.so.57 => /mnt/swdevel/DVStor/source_build/lib3p/libavcodec.so.57 (0xb623f000)
libstdc++.so.5 => /usr/local/dvstor/lib/libstdc++.so.5 (0xb616f000)
libm.so.6 => /lib/libm.so.6 (0xb6144000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6126000)
libc.so.6 => /lib/libc.so.6 (0xb5f8f000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb5f74000)
librt.so.1 => /lib/librt.so.1 (0xb5f6b000)
libdl.so.2 => /lib/libdl.so.2 (0xb5f65000)
libz.so.1 => /lib/libz.so.1 (0xb5f51000)
/lib/ld-linux.so.2 (0x00871000)
一切都在那里。我被卡住了......
答案 0 :(得分:4)
使用extern" C"围绕FFmpeg标题的include语句:
extern "C" {
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
[etc]
}
大多数图书馆都是为你做的,但出于某些哲学原因,FFmpeg并不这样做。
答案 1 :(得分:0)
备用方法(http://soledadpenades.com/2009/11/24/linking-with-ffmpegs-libav/)是通过以下格式链接到ffmpeg库来编译的:
gcc -o main.o main.c `pkg-config --cflags --libs libavformat libavutil`