In fact I am working on Linux (64-bit).
So, I code, compile and run on this system most of the time.
However, as I want to make my program compatible to Windows (32-bit), I have a
cross compiler on Linux.
So, I cross compile my program on Linux for Windows.
Then I copy my .exe from Linux to a directory on a computer that is running
Windows.
And the problem happens on Windows.
I am not using Wine.
Also, I did another simple test to see if the problem is on all my cross compiled eggs or
only on the "sdl2" egg.
I did the test with the "srfi-1" egg.
Here is what I did.
I have a program "main.scm":
$ cat main.scm
(import srfi-1)
(display (proper-list? 1))
(display (proper-list? '(1 2)))
Also, I have this Makefile:
$ cat Makefile
CSC ?= csc
CC=$(shell $(CSC) -cc-name | sed "s/'//g")
CFLAGS=$(shell $(CSC) -cflags | sed "s/'//g")
LDFLAGS=$(shell $(CSC) -ldflags | sed "s/'//g")
LDLIBS=$(shell $(CSC) -libs | sed "s/'//g")
.PHONY: all clean edit run
.SECONDARY: main.c
all: main.out
clean:
rm -fv *.c *.out
edit:
gvim -p *.scm
run:
./*.out
%.c: %.scm
$(CSC) -t -o $@ $<
%.out: %.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)
On Linux, I can compile my program:
$ make
csc -t -o main.c main.scm
gcc -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -O2
-fPIC -I/usr/include/chicken -o main.out main.c -L/usr/lib64
-Wl,-rpath=/usr/lib64 -lchicken -lm -ldl
Run it:
$ ./main.out
#f#t
So, I have the expected result.
Now, if I cross compile my program, on Linux, for Windows:
$ CSC=i686-w64-mingw32-csc make
i686-w64-mingw32-csc -t -o main.c main.scm
i686-w64-mingw32-gcc -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
-DC_ENABLE_PTABLES -Os -fomit-frame-pointer
-I/usr/i686-w64-mingw32/include/chicken -o main.out main.c
-L/usr/i686-w64-mingw32/lib -Wl,-rpath=/usr/i686-w64-mingw32/lib -lchicken -lm
-lws2_32
$ mv main.out main.exe
Run it on a windows machine.
I get some missing DLLs (libchicken.dll), so I add them to the same directory
as the .exe.
I get some missing Eggs (srfi-1.so), so I add them to the same directory as the
.exe.
Then here is the result:
main.out
#f#t
So, I have the expected result.
This means that I have no problem to cross compile then run my program that is using the
"srfi-1" egg.
So, I suspect that the problem is on the "sdl2" cross compiled egg.
This is how I cross compile my "sdl2" egg:
NAME="i686-w64-mingw32-chicken-sdl2"
VERSION="0.4.1"
DIR="sdl2-${VERSION}"
DESTDIR="/tmp/${NAME}-${VERSION}"
tar xvf ${DIR}.tar.gz
patch -p0 < ${NAME}-${VERSION}.patch
cd ${DIR}
CHICKEN_EGG_CACHE=/tmp/chicken-cache \
DESTDIR=${DESTDIR} \
i686-w64-mingw32-chicken-install -host
SDL2_CFLAGS="-I/usr/i686-w64-mingw32/include/SDL2" \
SDL2_LDFLAGS="-lSDL2" \
CHICKEN_EGG_CACHE=/tmp/chicken-cache \
DESTDIR=${DESTDIR} \
i686-w64-mingw32-chicken-install -target
cd -
rm -rfv ${DIR}
The patch used is this one:
$ cat i686-w64-mingw32-chicken-sdl2-0.4.1.patch
diff -ruN sdl2-0.4.1.ori/sdl2-features.scm sdl2-0.4.1/sdl2-features.scm
--- sdl2-0.4.1.ori/sdl2-features.scm 2026-09-14 02:18:37.549348266 +0200
+++ sdl2-0.4.1/sdl2-features.scm 2026-09-14 02:18:13.937877979 +0200
@@ -67,32 +67,17 @@
(register-feature! 'sdl2-0.3.0+)
(register-feature! 'sdl2-0.4.0+)
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,0)" bool)
- (register-feature! 'libSDL-2.0.0+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,1)" bool)
- (register-feature! 'libSDL-2.0.1+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,2)" bool)
- (register-feature! 'libSDL-2.0.2+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,3)" bool)
- (register-feature! 'libSDL-2.0.3+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,4)" bool)
- (register-feature! 'libSDL-2.0.4+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,5)" bool)
- (register-feature! 'libSDL-2.0.5+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,6)" bool)
- (register-feature! 'libSDL-2.0.6+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,7)" bool)
- (register-feature! 'libSDL-2.0.7+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,8)" bool)
- (register-feature! 'libSDL-2.0.8+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,9)" bool)
- (register-feature! 'libSDL-2.0.9+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,10)" bool)
- (register-feature! 'libSDL-2.0.10+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,12)" bool)
- (register-feature! 'libSDL-2.0.12+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,14)" bool)
- (register-feature! 'libSDL-2.0.14+))
- (if (foreign-value "SDL_VERSION_ATLEAST(2,0,16)" bool)
+ (register-feature! 'libSDL-2.0.0+)
+ (register-feature! 'libSDL-2.0.1+)
+ (register-feature! 'libSDL-2.0.2+)
+ (register-feature! 'libSDL-2.0.3+)
+ (register-feature! 'libSDL-2.0.4+)
+ (register-feature! 'libSDL-2.0.5+)
+ (register-feature! 'libSDL-2.0.6+)
+ (register-feature! 'libSDL-2.0.7+)
+ (register-feature! 'libSDL-2.0.8+)
+ (register-feature! 'libSDL-2.0.9+)
+ (register-feature! 'libSDL-2.0.10+)
+ (register-feature! 'libSDL-2.0.12+)
+ (register-feature! 'libSDL-2.0.14+)
(register-feature! 'libSDL-2.0.16+))
- )
Do you see why my program using the "sdl2" egg doesn't work whereas my program using the
"srfi-1" egg works?
Thank you.
Best regards.
On 16/09/2026 22:17, Felix Winkelmann wrote:
On Wed Sep 16, 2026 at 9:42 AM CEST, YuGiOhJCJ via Chicken-users wrote:
I get this error only with this program that is using an egg.
With the same method, I have no problem to run a .exe, that is not using an
egg, like a simple program that is doing factorial.
So, I am not sure what I am doing wrong, any idea please?
The error indicates that a PE executable for Windows is loaded as a source
file, the "MZ..." is the magic file header for the binary. Loading the
shared library seems to fail, so it is loaded as source code, causing
the error. I'm not exactly sure I understand your setup, are you running
the cross-compiled executable in WINE?
cheers,
felix