SDL2 with cross compiler


Edglex

Member
Joined
Oct 27, 2010
Messages
168
I've not done any pandora development for a long time and decided to get a toolchain set up so I can try building some stuff. I used crosscompilemaker.sh to get gcc/binutils/glibc built, but next I need SDL2. I found https://github.com/ptitSeb/SDL2 but the Makefile.pandora there was a bit broken (or unfinished/discarded?) and I don't have any of the dependencies installed. By trial and error I found that I need the following dependencies from the repo:

kbproto-dev_1.0.4-r1.5_armv7a.ipk
libx11-dev_1.3.3-r7.5_armv7a.ipk
xextproto-dev_7.1.1-r0.5_armv7a.ipk
libgles-omap3-es23-dev_4.00.00.01-r6.5_armv7a.ipk
libxext-dev_1.1.1-r1.5_armv7a.ipk
xproto-dev_7.0.16-r0.5_armv7a.ipk

I wrote a script to extract the ipk files:

Code:
fermat01:~/project/pandora_dev$ cat extract_ipk.sh
#!/bin/sh
ar -x $1 data.tar.gz
mkdir ${1%.*}
tar -xf data.tar.gz -C ${1%.*}
rm data.tar.gz

And I had to make some small changes to get it to build:
Code:
diff --git a/Makefile.pandora b/Makefile.pandora
index f4cb668..2622e29 100644
--- a/Makefile.pandora
+++ b/Makefile.pandora
@@ -1,18 +1,25 @@
 # Makefile to build the pandora SDL library
 
-AR     = arm-none-linux-gnueabi-ar
-RANLIB = arm-none-linux-gnueabi-ranlib
-CC = arm-none-linux-gnueabi-gcc
-CXX = arm-none-linux-gnueabi-g++
-STRIP = arm-none-linux-gnueabi-strip
+AR     = armv7l-unknown-linux-gnueabi-ar
+RANLIB = armv7l-unknown-linux-gnueabi-ranlib
+CC = armv7l-unknown-linux-gnueabi-gcc
+CXX = armv7l-unknown-linux-gnueabi-g++
+STRIP = armv7l-unknown-linux-gnueabi-strip
 
 CFLAGS  = -O3 -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp \
        -mfpu=neon -ftree-vectorize -ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant \
-       -I./include -I$(PNDSDK)/usr/include
+       -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1 \
+       -I./include \
+       -I/home/edglex/project/pandora_dev/xproto-dev_7.0.16-r0.5_armv7a/usr/include \
+       -I/home/edglex/project/pandora_dev/libx11-dev_1.3.3-r7.5_armv7a/usr/include \
+       -I/home/edglex/project/pandora_dev/libgles-omap3-es23-dev_4.00.00.01-r6.5_armv7a/usr/include \
+       -I/home/edglex/project/pandora_dev/libxext-dev_1.1.1-r1.5_armv7a/usr/include \
+       -I/home/edglex/project/pandora_dev/xextproto-dev_7.1.1-r0.5_armv7a/usr/include \
+       -I/home/edglex/project/pandora_dev/kbproto-dev_1.0.4-r1.5_armv7a/usr/include
 
 TARGET  = libSDL.a
 
-SOURCES =
+SOURCES = \
        ./src/*.c \
        ./src/atomic/*.c \
        ./src/audio/*.c \
diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c
index 4e4f8a5..f60e174 100644
--- a/src/haptic/linux/SDL_syshaptic.c
+++ b/src/haptic/linux/SDL_syshaptic.c
@@ -37,6 +37,7 @@
 #include <errno.h>              /* errno, strerror */
 #include <math.h>               /* atan2 */
 #include <sys/stat.h>           /* stat */
+#include <linux/limits.h>       /* PATH_MAX */
 
 /* Just in case. */
 #ifndef M_PI
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 407749c..f7f40e8 100755
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -31,7 +31,7 @@
 #include <sys/stat.h>
 #include <errno.h>              /* errno, strerror */
 #include <fcntl.h>
-#include <limits.h>             /* For the definition of PATH_MAX */
+#include <linux/limits.h>       /* For the definition of PATH_MAX */
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <linux/joystick.h>

(I know that I should probably use a single target/usr/include directory, but it was easier to do it this way for testing which packages were needed).

At the end I get libSDL.a, though I haven't tried it yet.

My question really is: Is this the "right" way to do this? Is this SDL2 repository still relevant and should I even be using Makefile.pandora? Is there a newer way to do this? I don't really want to do development on my pandora itself and my understanding is that the code::blocks PND, which already incldues SDL2, is for that. Thanks
 
  • Like
Reactions: rSl
libSDL.a is the static library. I could change the makefile to produce a shared library but static is fine for now. See for example https://stackoverflow.com/questions/9809213/what-are-a-and-so-files

Edit:
To produce libSDL2.so using the above repo:
Code:
diff --git a/Makefile.pandora b/Makefile.pandora
index f4cb668..5e84b77 100644
--- a/Makefile.pandora
+++ b/Makefile.pandora
@@ -1,18 +1,25 @@
 # Makefile to build the pandora SDL library
 
-AR     = arm-none-linux-gnueabi-ar
-RANLIB = arm-none-linux-gnueabi-ranlib
-CC = arm-none-linux-gnueabi-gcc
-CXX = arm-none-linux-gnueabi-g++
-STRIP = arm-none-linux-gnueabi-strip
+AR     = armv7l-unknown-linux-gnueabi-ar
+RANLIB = armv7l-unknown-linux-gnueabi-ranlib
+CC = armv7l-unknown-linux-gnueabi-gcc
+CXX = armv7l-unknown-linux-gnueabi-g++
+STRIP = armv7l-unknown-linux-gnueabi-strip
 
 CFLAGS  = -O3 -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp \
-       -mfpu=neon -ftree-vectorize -ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant \
-       -I./include -I$(PNDSDK)/usr/include
+       -mfpu=neon -ftree-vectorize -ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant -fPIC \
+       -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1 \
+       -I./include \
+       -I/home/ed/project/pandora_dev/xproto-dev_7.0.16-r0.5_armv7a/usr/include \
+       -I/home/ed/project/pandora_dev/libx11-dev_1.3.3-r7.5_armv7a/usr/include \
+       -I/home/ed/project/pandora_dev/libgles-omap3-es23-dev_4.00.00.01-r6.5_armv7a/usr/include \
+       -I/home/ed/project/pandora_dev/libxext-dev_1.1.1-r1.5_armv7a/usr/include \
+       -I/home/ed/project/pandora_dev/xextproto-dev_7.1.1-r0.5_armv7a/usr/include \
+       -I/home/ed/project/pandora_dev/kbproto-dev_1.0.4-r1.5_armv7a/usr/include
 
-TARGET  = libSDL.a
+TARGET  = libSDL2.so
 
-SOURCES =
+SOURCES = \
        ./src/*.c \
        ./src/atomic/*.c \
        ./src/audio/*.c \
@@ -53,8 +60,7 @@ CONFIG_H = $(shell cp include/SDL_config_pandora.h include/SDL_config.h)
 all: $(TARGET)
 
 $(TARGET): $(CONFIG_H) $(OBJECTS)
-       $(AR) crv $@ $^
-       $(RANLIB) $@
+       $(CC) $(CFLAGS) -shared -o $@ $^
 
 clean:
        rm -f $(TARGET) $(OBJECTS)

Can @ptitSeb perhaps help answer my question? :)
 
Last edited:
Thanks @ptitSeb :)

I have a pandoratoolchain.cmake file. Can you give a simple pointer to configuring SDL2 for pandora with cmake? (When I run I get -- HAVE_PANDORA (Wanted: ON): OFF)
 
Last edited:
Well SDL1 works nicely in any case :)
Will get back to SDL2 tonight
P1050810.JPG
 
Is this SDL2 repository still relevant and should I even be using Makefile.pandora? Is there a newer way to do this?
I believe the repository you're trying to use has long been merged into the mainline SDL repo. At the very least Makefile.pandora has been part of it for the same 3 years.
Though I say that as someone who has no experience building SDL2 for Pandora manually. Just wanted to hint at that the mainline repo is at least to supposed to support the Pandora still.

Though after what ptitSeb said with the makefiles being obsolete, I'm kinda worried about the ones lingering around there. Not many people affected and even less having time to maintain while alternatives exists, I guess?
 
My repo includes all the hacks to have SDL2 working on Pandora, including the EGL changes to be compatible with latest SGX driver, and the definition of the keyboard... Many of the hacks are not "upstream" compatible. It's just hack. I advise using my repo for the Pandora, not upstream (even if my version is a bit old, I know)
 
Last edited:
Back
Top