Cygwin & SDL_image

Hi,
I have seen several postings and messages regarding cygwin, SDL &
SDL_image. Perhaps these are common enough now to belong in a FAQ?
Unfortunately I haven’t managed to extract enough information to answer all
my questions. Perhaps someone could help fill in the gaps.
Regards,
Bruce A.

  1. SDL is configured to compile using -mno-cygwin under cygwin

This seems to mean that we are actually compiling for mingw32.
This is confusing for many of us cygwin users who are using cygwin
partly because we believe in POSIX compliance.
(I also believe in ISO C++ compliance and hence mostly avoid VC++)
It would be helpful to have an enable disable switch on configure to
control this behaviour. I found a recent poster who also suggested this
so I am clearly not alone.

I’m not up to speed on hacking configure. I tried editing configure &
configure.in manually to remove -mno-cygwin and -I/usr/include/mingw32
but it didn’t have the desired effect. After running configure, make did the
following:

F:\PROJECTS_OVERFLOW\Download\SDL\SDL-1.2.7>make
cd . && aclocal-1.8
/bin/bash: line 1: aclocal-1.8: command not found
make: *** [aclocal.m4] Error 127

Make worked correctly before my failed hack.
What is the correct way to do this. How could we go about patching configure to
add --enable-cygwin properly?

  1. SDL_image

This seems an almost essential package why is not part of the core SDL
distribution?

The binary distribution for windows does not contain showimage.c contrary
to the README included.

  1. SDL_image source & cygwin

This seems to have a problem finding the jpeg headers when compiling.
Though they are there under /usr/include
(cygwin/usr/include that is - if the distinction makes any difference)
Possibly it is looking for them under /usr/include/mingw32?
Adding them manually to the source directory compilation then has a number
of errors:

gcc -DPACKAGE=“SDL_image” -DVERSION=“1.2.3” -I. -I. -g -O2 -I/usr/local/incl
ude/SDL -Dmain=SDL_main -I/usr/include/mingw -DWIN32 -Uunix -mno-cygwin -DLOAD_B
MP -DLOAD_GIF -DLOAD_JPG -DLOAD_LBM -DLOAD_PCX -DLOAD_PNG -DLOAD_PNM -DLOAD_TGA
-DLOAD_XPM -c IMG_jpg.c -DPIC -o .libs/IMG_jpg.lo
In file included from IMG_jpg.c:35:
jpeglib.h:30:61: jmorecfg.h: No such file or directory
In file included from IMG_jpg.c:35:
jpeglib.h:71: error: syntax error before "FAR"
jpeglib.h:71: warning: data definition has no type or storage class
jpeglib.h:72: error: syntax error before ‘’ token
jpeglib.h:72: warning: data definition has no type or storage class
jpeglib.h:73: error: syntax error before '
’ token
jpeglib.h:73: warning: data definition has no type or storage class
jpeglib.h:75: error: syntax error before “JBLOCK”
[snip]
jpeglib.h:1076: error: syntax error before "jpeg_resync_to_restart"
jpeglib.h:1077: warning: data definition has no type or storage class
IMG_jpg.c:62: error: field `pub’ has incomplete type
IMG_jpg.c:66: confused by earlier errors, bailing out
make: *** [IMG_jpg.lo] Error 1

Note this is compiling out of the box with no hackery to try and make it
use cygwin rather than mingw.

This means I can’t get beyond square one and compile showimage
let alone a bigger program such as kobo deluxe.

  1. SDL_image binary - showimage

I have so far failed in my attempts to compile a working showimage.c from the
SDL_image source using the installed mingw32 binaries.
I have tried various combinations of options. An example cygwin makefile with
showimage.c in the binary package would be very helpful.

I either end up with unresolved _winmain at 16 or unresolved __getreent in the
best case.
As a workaround for _winmain at 16 I found some code on the net which uses
GetCommandLine() in winmain to call the normal main(argc,argv).
I’m sure this is not necessary with the right options.
Something is still not right because running the resulting .exe gives:

E:\projects\SDLtest>showimage
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

E:\projects\SDLtest>showimage testimage.jpg
Couldn’t load testimage.jpg:
Couldn’t load ?%?:
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

showimage.exe: showimage.o argumentvector.o
$(LINK) $< argumentvector.o -o$@ $(CLIB) /usr/local/lib/libSDL_image.a
/usr/local/lib/libSDLmain.a /usr/local/lib/libSDL.a /usr/local/lib/libSDL_mixer.
a -lgdi32 -lwinmm -ljpeg -lpng -lz -mno-cygwin -lmingw32

I saw this suggested - it didn’t work for me

-e _WinMainCRTStartup

showimage.o: showimage.c argumentvector.h
$(CC) -x c++ -c -I/usr/local/include/SDL -I…/libraries/include -o$@ $<
-mno-cygwin>From my makefile:


NB to make showimage.c happy with -x c++ a cast is needed here:

void draw_background(SDL_Surface *screen)
{
Uint8 dst = (Uint8)screen->pixels;

C/C++ does really matter here. I only did it to allow me to try both
-lc and -lstdc++ which made no difference.

Hopefully someone out there can help answer some of these questions.
I am happy to help on a cygwin porting effort if there is anything useful
I can do.
Regards,
Bruce A.