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.
CodePudding user response:
@user17732522 helped me work through a couple of issues:
- several flags were out of order:
.o
files should come before-l
options-lfreetype
must come after-lSDL_ttf
)
- 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