我已经用MSYS(用于MinGW)构建了libvpx.a和头文件。当我尝试编译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已链接...
那我在做什么错?
PS:也许仅仅链接libvpx.a文件还不够,我还需要源文件随附的.c文件(如果这样,我不知道需要什么.a lib文件)?
最佳答案
看起来您只是从示例中盲目复制并粘贴了代码。
函数die_codec
和vpx_video_*
都来自tools_common.c
(https://github.com/webmproject/libvpx/blob/master/tools_common.c)和video_reader.h
(https://github.com/webmproject/libvpx/blob/master/video_reader.c),我相信它们不是libvpx sdk的核心部分(请参见此处:http://www.webmproject.org/docs/webm-sdk/files.html) 。
为了使示例生效,您还需要复制粘贴这些文件(.c
和.h
文件),并将它们包括在main.cc
文件中。