Buildroot 交叉编译 - 编译有效但链接找不到各种 SDL 函数

Buildroot cross-compiling - compile works but linking can't find various SDL functions

some code 我可以使用使用 uClibc 的旧工具链进行交叉编译,但该项目正在转移到 musl libc,我似乎无法获得使用该工具链进行编译的代码.它总是在链接阶段失败,并出现以下这些错误:

/opt/miyoo/bin/../lib/gcc/arm-buildroot-linux-musleabi/11.2.0/../../../../arm-buildroot-linux-musleabi/bin/ld: objs/miyoo/src/touchscreen.o: in function `Touchscreen::poll()':
/__w/gmenunx/gmenunx/src/touchscreen.cpp:87: undefined reference to `SDL_PumpEvents'
/opt/miyoo/bin/../lib/gcc/arm-buildroot-linux-musleabi/11.2.0/../../../../arm-buildroot-linux-musleabi/bin/ld: /__w/gmenunx/gmenunx/src/touchscreen.cpp:89: undefined reference to `SDL_GetMouseState'
/opt/miyoo/bin/../lib/gcc/arm-buildroot-linux-musleabi/11.2.0/../../../../arm-buildroot-linux-musleabi/bin/ld: objs/miyoo/src/surface.o: in function `Surface::Surface(SDL_Surface*, SDL_PixelFormat*, unsigned int)':
/__w/gmenunx/gmenunx/src/surface.cpp:74: undefined reference to `SDL_ConvertSurface'

有一些我不确定是不是 SDL 的东西,例如 IMG_LoadPNG_RWTTF_Init,但在大多数情况下,链接器可以做到的都是 SDL_Whatever 'find,就在编译器刚刚找到它之后。

您可以看到 full output from the failing musl build (linking starts on line 857), and compare it to a working uClibc build(链接从第 863 行开始)。

我试过将 buildroot 设置从静态更改为动态,以及两者都更改,但这并没有改变任何东西。我还尝试添加 SDL2,尽管我相当确定代码实际上依赖于 SDL 1,但是当我启用 SDL2 时我无法让 buildroot 制作工具链。我尝试了其他一些方法,例如切换参数顺序,但 none 似乎解决了问题。


对于上下文,我正在尝试构建一个 docker 图像,可用于在 GitHub 操作中为 MiyooCFW 交叉编译软件。

我调整了 docker image with the old toolchain and created a new one with the new toolchain 以便我们可以在 GitHub 操作中构建两者。

这是我用于 musl 工具链的 buildroot 存储库:https://github.com/nfriedly/buildroot

uClibc 工具链在 .7z file on google drive, but I'm not sure where the source for it is. There is also some (incomplete) documentation.

中可用

我对这些东西的大部分内容都是菜鸟,所以很可能有一些明显的东西是我遗漏的。

@user17732522 帮助我解决了几个问题:

  1. 几个标志乱序:
  • .o 文件应该在 -l 选项之前
  • -lfreetype 必须在 -lSDL_ttf)
  • 之后
  1. 缺少几个标志:
  • -ljpeg -lpng -lz-lSDL_image
  • 之后
  • -lvorbisfile -lvorbis -logg-lSDL_mixer
  • 之后
  • -lbz2 -lmpg123最后

此 PR 具有允许它在新工具链上编译的修复(不会中断旧工具链上的编译):https://github.com/MiyooCFW/gmenunx/pull/12