dethrace-labs/dethrace

Compilation issue cross compiling for Miyoo mini +

Closed this issue ยท 10 comments

I tried compiling your super cool project ๐Ÿฅ‡
So gave it a shot with compiling SDL2 and dethrace
but got stuck on a linker error related to something with the brender software mode:

[ 97%] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/pc-win95/win95sys.c.o
[ 97%] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/pc-win95/ssdx.c.o
[ 98%] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/pc-win95/win95net.c.o
[ 98%] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/pc-dos/dosnet.c.o
[ 99%] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/pc-dos/dossys.c.o
[ 99%] Built target dethrace_obj
Scanning dependencies of target dethrace
[ 99%] Building C object src/DETHRACE/CMakeFiles/dethrace.dir/main.c.o
[100%] Linking C executable ../../dethrace
CMakeFiles/dethrace.dir/main.c.o: In function _BrBeginHook': main.c:(.text+0x3c): undefined reference to BrDrv1SoftPrimBegin'
main.c:(.text+0x40): undefined reference to `BrDrv1SoftRendBegin'
collect2: error: ld returned 1 exit status
make[2]: *** [src/DETHRACE/CMakeFiles/dethrace.dir/build.make:211: dethrace] Error 1
make[1]: *** [CMakeFiles/Makefile2:1067: src/DETHRACE/CMakeFiles/dethrace.dir/all] Error 2
make: *** [Makefile:87: all] Error 2

This was my commandline:

`export PATH=/opt/mmiyoo/bin/:$PATH

rm -rf dethrace
git clone https://github.com/dethrace-labs/dethrace.git
cd dethrace
git submodule update --init --recursive
sed -i '35i ../x86emu/include/x86emu.h ../x86emu/x86emu.c' ./lib/BRender-v1.3.2/drivers/softrend/CMakeLists.txt
sed -i '80i ../x86emu/include/x86emu.h ../x86emu/x86emu.c' ./lib/BRender-v1.3.2/drivers/pentprim/CMakeLists.txt
cat ./lib/BRender-v1.3.2/drivers/softrend/CMakeLists.txt

mkdir -p build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/mmiyoo/share/buildroot/toolchainfile.cmake --host=/opt/mmiyoo/share/buildroot/toolchainfile.cmake ..
make`

What could be going wrong for the linker not to find BrDrv1SoftPrimBegin or BrDrv1SoftRendBegin?

Maybe something to do with the recent changes to Brender? also, I needed to hack the x86emu in the included files, otherwise it could not find it.

I did the compilation on colab.google.com,

Can you please clean up the colab notebook so it can be run from start to finish?
Remove unused commands, and perhaps document why you run certain commands.
It's a bit of a mess right now.

only the penultimate codeblock is relevant, you should be able to repeat that one.

I'm adding comments as we speak, and fixing it from start to end again.

(building sdl2 on colab takes about 40 minutes this way, you should be able to use the already compiled files in the workspace, and just only run code block 3, the one that compiles dethrace)

Thanks. It would be interesting to see the actual commands, by running make VERBOSE=y instead of only make.

I've added VERBOSE=y and ran it once, so the logs are already there, maybe that will help finding the issue.

Also it should work from start to end, and added the necessary comments. remember though, building SDL2 takes about an hour using free colab, and is probably not necessary if you only run step [3]

seems like this issue is related to what version of cmake is used.

see also #377

I updated the project to use cmake 3.29.2, now it builds ok ๐Ÿ‘

What version causes you grief?
Perhaps I can troubleshoot it on Linux.

3.27.9 installed by ubuntu jammy.

installing 3.29.2 from source seems to fix all issues. (except me not understanding how to compile against the sdl2_miyoo folder, how to include it etc)

The colab project now produces a working binary! I need to pass --no-signal-handler, otherwise it crashes.

Also, sadly, the sound does not work, because (i think) alsa is borked on Onion OS (missing audio group?), and like OSS also doesn't compile because of an incompatible linux/soundcard.h.

A solution would be to create a customBackend for miniaudio that supports outputting through SDL.

or maybe enable the alsa output with amixer,like

amixer set 'DACL Mixer AIF1DA0L' on

amixer get 'DACL Mixer AIF1DA0L' | grep "Mono: Playback \[off\]"

see https://github.com/steward-fu/nds/blob/master/alsa/main.c