gpt4 book ai didi

c - Eclipse 中的树莓派交叉编译

转载 作者:行者123 更新时间:2023-11-30 16:44:34 24 4
gpt4 key购买 nike

我想在 Eclipse 中(在 Windows 中)编译 Raspberry 应用程序。我安装了 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 是库链接器需要的(可能不是全部)他们)。请注意,顺序很重要。

最佳答案

不需要为Raspberry PI编译FFMPEG源。
您可以使用 apt-get 或其他包管理器安装它,然后您可以使用“avcodec.h”来设计您的应用程序,由 GCC 在 Raspberry 主机中构建。

关于c - Eclipse 中的树莓派交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44424410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com