我想在Eclipse中编译Raspberry的应用程序(在windows中)。我安装了SysGCC,配置了Eclipse进行交叉编译。如果我创造类似" Hello world" - 一切都好。 Eclipse创建的二进制文件非常适用于Raspberry。 但我需要在我的应用程序中使用FFMPEG库。这里是最小的应用代码:
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
int main(void) {
av_register_all();
return EXIT_SUCCESS;
}
我在项目配置中添加了库。项目编译良好,但链接器会产生很多错误:
C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib\libavcodec.a(aaccoder.o): In function `quantize_and_encode_band_cost_template':
/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: undefined reference to `cbrtf'
/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: undefined reference to `cbrtf'
/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: undefined reference to `cbrtf'
/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: undefined reference to `cbrtf'
C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib\libavcodec.a(aacenc_is.o): In function `quantize_and_encode_band_cost_template':
/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: undefined reference to `cbrtf'
C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib\libavcodec.a(aacenc_is.o):/usr/src/ffmpeg/libavcodec/aacenc_quantization.h:108: more undefined references to `cbrtf' follow
C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib\libavcodec.a(adx.o): In function `ff_adx_calculate_coeffs':
/usr/src/ffmpeg/libavcodec/adx.c:30: undefined reference to `cos'
/usr/src/ffmpeg/libavcodec/adx.c:34: undefined reference to `lrintf'
/usr/src/ffmpeg/libavcodec/adx.c:35: undefined reference to `lrintf'
/usr/src/ffmpeg/libavcodec/adx.c:30: undefined reference to `cos'
/usr/src/ffmpeg/libavcodec/adx.c:34: undefined reference to `lrintf'
/usr/src/ffmpeg/libavcodec/adx.c:35: undefined reference to `lrintf'
collect2.exe: error: ld returned 1 exit status
make: *** [ffmpeg] Error 1
02:21:24 Build Finished (took 8s.394ms)
解决:
我使用了下一个命令:
arm-linux-gnueabihf-gcc -L"C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"C:\SysGCC\Raspberry\arm-linux-gnueabihf\lib" -o "ffmpeg" ./src/ffmpeg.o -lc -lm -lpthread -lavformat -lavcodec -lswscale -lavutil -lavfilter -lavdevice -lswresample -lpostproc -ldl -lx264 -lgcc -lz
其中 -lc -lm -lpthread -lavformat -lavcodec -lswscale -lavutil -lavfilter -lavdevice -lswresample -lpostproc -ldl -lx264 -lgcc -lz 是链接器需要的库(可能不是全部的他们)。 请注意,订单很重要。
答案 0 :(得分:0)
Raspberry PI不需要编译FFMPEG源。
您可以使用apt-get或其他程序包管理器进行安装,然后可以使用“ avcodec.h”设计应用程序,该应用程序由GCC在Raspberry主机中构建。