Buildroot 交叉编译 - 编译可以工作,但链接无法找到各种 SDL 函数

发布于 2025-01-10 03:37:46 字数 2353 浏览 3 评论 0原文

我有 一些代码,我可以与使用 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,但在大多数情况下,编译器刚刚找到它之后,链接器就找不到它了。

您可以看到失败的 musl 构建的完整输出(链接从第 857 行开始),并将其与工作 uClibc 版本(链接开始在线863)。

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


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

我使用旧工具链调整了 docker 镜像使用新工具链创建了一个新工具链这样我们就可以在 GitHub Actions 中构建两者。

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

uClibc 工具链可在 Google 云端硬盘上的 .7z 文件,但我不确定在哪里它的来源是。还有一些(不完整)文档


对于大多数这些东西,我都是菜鸟,所以很可能有一些明显的东西我只是错过了。

I have some code that I could cross-compile with an older toolchain that used uClibc, but the project is moving to musl libc, and I can't seem to get the code to compile with that toolchain. It always fails during the linking stage with a bunch of errors along these lines:

/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'

There are a couple that I'm not sure are SDL things, such as IMG_LoadPNG_RW and TTF_Init, but for the most part, it's all SDL_Whatever that the linker can't find, right after the compiler just found it.

You can see the full output from the failing musl build (linking starts on line 857), and compare it to a working uClibc build (linking starts on line 863).

I tried messing around with changing the buildroot settings from static to dynamic, and also both, but that didn't change anything. I also tried adding SDL2, even though I'm fairly certain the code actually depends on SDL 1, but I couldn't get buildroot to make the toolchain when I had SDL2 enabled. I tried some other things like switching around argument orders, but none of it seemed to solve the issue.


For context, I'm trying to build a docker image that can be used to cross-compile software for MiyooCFW in GitHub Actions.

I tweaked a docker image with the old toolchain and created a new one with the new toolchain so that we could build both in GitHub Actions.

This is the buildroot repo I used for the musl toolchain: https://github.com/nfriedly/buildroot

The uClibc toolchain is available in a .7z file on google drive, but I'm not sure where the source for it is. There is also some (incomplete) documentation.


I'm a noob when it comes to most of this stuff, so there may very well be something obvious that I'm just missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2025-01-17 03:37:46

@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

@user17732522 helped me work through a couple of issues:

  1. several flags were out of order:
  • .o files should come before -l options
  • -lfreetype must come after -lSDL_ttf)
  1. several flags were missing:
  • -ljpeg -lpng -lz after -lSDL_image
  • -lvorbisfile -lvorbis -logg after -lSDL_mixer
  • -lbz2 -lmpg123 at the end

This PR has the fixes that allow it to compile on the new toolchain (without breaking compiling on the old one): https://github.com/MiyooCFW/gmenunx/pull/12

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文