使用 libvpx 编译项目时未定义的引用

Undefined references when compiling project with libvpx

我已经使用 MSYS(对于 MinGW)构建了 libvpx.a 和 headers。当我尝试编译 example 时,出现了很多对 vpx 成员的未定义引用:

g++ -m32 -static    -o dist/Debug/MinGW-Windows/test1 build/Debug/MinGW-Windows/main.o -L/D/Libraries/libvpx/ -lvpx
build/Debug/MinGW-Windows/main.o: In function `main':
D:\Projects\CPP_test\Test1/main.cpp:107: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:109: undefined reference to `vpx_video_reader_open'
D:\Projects\CPP_test\Test1/main.cpp:111: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:114: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:116: undefined reference to `vpx_video_reader_get_info'
D:\Projects\CPP_test\Test1/main.cpp:118: undefined reference to `get_vpx_decoder_by_fourcc'
D:\Projects\CPP_test\Test1/main.cpp:120: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:125: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:127: undefined reference to `vpx_video_reader_read_frame'
D:\Projects\CPP_test\Test1/main.cpp:132: undefined reference to `vpx_video_reader_get_frame'
D:\Projects\CPP_test\Test1/main.cpp:134: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:137: undefined reference to `vpx_img_write'
D:\Projects\CPP_test\Test1/main.cpp:144: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:149: undefined reference to `vpx_video_reader_close'

所有内容均已制作,lib 已 linked... 那我做错了什么?

PS: link 可能还不够 libvpx.a 文件,我还需要源码自带的.c文件(如果是的话,我不明白.a lib 文件需要什么)?

看起来你只是从示例中盲目复制和粘贴。

函数die_codecvpx_video_*都来自tools_common.c(https://github.com/webmproject/libvpx/blob/master/tools_common.c) and video_reader.h (https://github.com/webmproject/libvpx/blob/master/video_reader.c), which I believe is not a core part of the libvpx sdk (see here: http://www.webmproject.org/docs/webm-sdk/files.html).

为了让您的示例正常工作,您还需要复制粘贴这些文件(.c.h 文件)并将它们包含在您的 main.cc 中文件。