geoffdaddy / adamem_sdl

ADAMEM SDL Port using SDL 2.0 library
2 stars 1 forks source link

Compilation error on Rasperry Pi OS (12 Bookwork) 64-bit #1

Open mrgw454 opened 10 months ago

mrgw454 commented 10 months ago

Hello,

Trying to compile adamem on a new Raspberry Pi 5 system and getting the following error:

IDE/HarddiskIDE.c:247:12: warning: variable ‘totalSectors’ set but not used [-Wunused-but-set-variable]
  247 |     UInt32 totalSectors;
      |            ^~~~~~~~~~~~
gcc      -Wall -Wformat=0 -O2 -fomit-frame-pointer -IIDE -DLSB_FIRST -DSDL -DDEBUG -DSOUND -DSOUND_PSG -DIDEHD -I/usr/include/SDL2   -c -o sms_ntsc.o sms_ntsc.c
gcc      -s -o adamem ADAMEm.o Coleco.o Z80.o AdamemSDL.o AdamSDLSound_2.o Sound.o Z80Debug.o Bitmap.o HarddiskIDE.o sms_ntsc.o -lz `sdl2-config --static-libs` -lm
/usr/bin/sdl2-config: 61: : Permission denied
/usr/bin/ld: cannot find /usr/lib//libSDL2.a: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile.SDL:23: adamem] Error 1
make[1]: Leaving directory '/home/pi/source/adamem_sdl'
make: *** [Makefile:22: sdl] Error 2

I used the command:

make sdl

... to compile.

I have sdl2 2.26.5 installed.

The missing file shown in the error is located on the system:

pi@raspberrypi:~/source $ ls -l /usr/lib/aarch64-linux-gnu/libSDL2.a
-rw-r--r-- 1 root root 3513644 Apr 12  2023 /usr/lib/aarch64-linux-gnu/libSDL2.a

Any help you can provide would be appreciated. Thank you!

geoffdaddy commented 10 months ago

Check the exec permissions on sdl2-config. Doesn't look like it was able to execute that during linking.

mrgw454 commented 10 months ago

I noticed that error as well, but permissions are good (running as user pi):

pi@raspberrypi:~ $ sdl2-config --version
2.26.5
pi@raspberrypi:~ $ whoami
pi
pi@raspberrypi:~ $
pi@raspberrypi:~ $ which sdl2-config
/usr/bin/sdl2-config
pi@raspberrypi:~ $ ls -l /usr/bin/sdl2-config
-rwxr-xr-x 1 root root 1999 Apr 12  2023 /usr/bin/sdl2-config

It could be that is a false error, perhaps due to something else?

mrgw454 commented 10 months ago

Based on this line:

/usr/bin/ld: cannot find /usr/lib//libSDL2.a: No such file or directory It looks like the linker is unable to determine the architecture type for the system. Is that why you see two // characters in the path?

Here's where the file is on my system:

/usr/lib/aarch64-linux-gnu/libSDL2.a

geoffdaddy commented 10 months ago

yeah, the linker can't find it because of the sdl2-config issue. That is a script that is included with SDL to provide appropriate linker options to the linker when using the --static-libs option. Try running that utility script directly with --static-libs and see what it shows. (could also try running the build with sudo, but that shouldn't be necessary if things are working properly).

geoffdaddy commented 10 months ago

(see Makefile.SDL) line 23.

mrgw454 commented 10 months ago

Interesting -- that script is included in this package:

pi@raspberrypi:~/source/adamem_sdl $ dpkg -S /usr/bin/sdl2-config
libsdl2-dev:arm64: /usr/bin/sdl2-config

Running it throws the error:

pi@raspberrypi:~/source/adamem_sdl $ sdl2-config --static-libs
/usr/bin/sdl2-config: 61: : Permission denied
/usr/lib//libSDL2.a -lm -lasound -lm -ldl -lpthread -lpulse-simple -lpulse -pthread -lsamplerate -lX11 -lXext -lXcursor -lXi -lXfixes -lXrandr -lXss -ldrm -lgbm -lwayland-egl -lwayland-client -lwayland-cursor -lxkbcommon -ldecor-0 -lpthread -lrt

Seems like a significant bug for that utility. I wonder if there's a work-around (rather than run as root)?

I appreciate your help with this as I'm a big fan of your emulator and wanted to get it going on the RPi5 (like it is on my RPi4 and RPi400).

Thank you!

geoffdaddy commented 10 months ago

That is very strange. Well, you should be able to cut-and-paste that line it spit out into the Makefile in place of the call to sdl2-config and it should work I would imagine. Glad to hear you like it and are making use of it. I haven't tried it on that new of a distribution of RPi linux or SDL2 but I have used it before when I had it working in SDL 1.2.

mrgw454 commented 10 months ago

Adding the output from sdl2-config (also fixing the path to the libSDL2.a file) to the Makefile.SDL worked! I tried to search for anyone else with issues using the sdl2-config utility (from the latest 64 bit Raspberry Pi OS 12 Bookworm) but nothing has turned up so far. I have to imagine this issue will present itself soon since that is a common utility to use.

Here's the sed line I used to fix the Makefile.SDL:

sed -i 's|sdl2-config --static-libs|/usr/lib/aarch64-linux-gnu/libSDL2.a -lm -lasound -lm -ldl -lpthread -lpulse-simple -lpulse -pthread -lsamplerate -lX11 -lXext -lXcursor -lXi -lXfixes -lXrandr -lXss -ldrm -lgbm -lwayland-egl -lwayland-client -lwayland-cursor -lxkbcommon -ldecor-0 -lpthread -lrt|' Makefile.SDL

In any case, thank you so much again for all your help. I hope this information might be useful to anyone else using the same platform and OS version.

geoffdaddy commented 10 months ago

From what I've read of it, it's a script and not a binary, so maybe if you add a '-x' to the #!/bin/sh line at the beginning of the script it would provide some additional clues of what's going on... strange.