SDL and Cygwin

Hello

I am experiencing some problems when I compile SDL with cygwin.

for example,
.libs/libSDL.lax/libaudio.al/SDL_diskaudio.lo: In function
DISKAUD_OpenAudio': /applis/SDL-1.2.3/src/audio/disk/SDL_diskaudio.c:215: undefined reference to_impure_ptr’
.libs/libSDL.lax/libvideo.al/SDL_nullvideo.lo: In function
DUMMY_VideoInit': /applis/SDL-1.2.3/src/video/dummy/SDL_nullvideo.c:153: undefined reference to_impure_ptr’

It seems to be related to std*
I can redefine std* to make it compile, but in this case I
have problems at execution.

Another problem is :

/applis/SDL-1.2.3/test/testcdrom.c:99: undefined reference to
`imp___ctype
It seems to be related to is_digit

Any ideas ?
Vivien

“Acc?dez au courrier ?lectronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,13 ?/mn) ; t?l : 08 92 68 13 50 (0,34?/mn)”

Hello SDL Developpers,

First of all, I would like to thank you for your work on SDL. It is of great
help when it comes to write cross-plateform multimedia applications !

I’m posting today to expose a trouble we have with SDL to port ARAnyM (
http://aranym.sf.net - an ATARI 16/32 bits compatible virtual machine) to
Windows.

This GPL software was originaly written on linux using SDL. When we tried to
port it to Windows we decided to use Cygwin, since (as opposed to MinGW) it
would avoid rewritting a lot of code. Unfortunatly, sdl-config script enforce a
MinGW compilation though the “-mno-cygwin” GCC flag.

We did not understand the reason of our problems at the beginning. The first
Windows compilation was done almost by error, when a developper compiled
without using sdl-config.

Currently, we use a script that hacks sdl-config to allow a real Cygwin
compilation by removing some flags with sed this way :

8<--------8<--------8<--------8<--------8<--------8<--------
sed -f- -i.bak sdl-config << EOF
s/-Dmain=SDL_main//
s=-I/usr/include/mingw==
s/-DWIN32//
s/-Uunix//
s/-mno-cygwin//
s/-lmingw32//
s/-lSDLmain//
s/-mwindows//
EOF
8<--------8<--------8<--------8<--------8<--------8<--------

Full script is available at
http://www.sophics.cz/cgi-bin/cvsweb/aranym/doc/build-cygwin.sh?rev=1.5 .

As you can see, I had to remove “-Dmain=SDL_main”, as GCC could not link with
it. This means that, in our Windows binary, SDLmain::WinMain/console_main is
not called at startup, and can’t initialize SDL or parse command line. Still,
ARAnyM seems to run quite well.

Anyway, I would like to throw away this dirty hack.

The best way, IMHO, to do so would be to have an SDL that can link with a Cygwin
binary. I guess this means creating a new target OS for SDL. An SDL lib linked
with Cygwin would have the advantage to be able to interpret Cygwin paths
(like, say, “/usr/local/aranym/font8.bmp”). This would ease porting application
since Cygwin makes Windows more posix-like. This means that a SDL program that
compiles on linux has great chances to compile also on Cygwin without the work
needed to support native Windows environnment like with MinGW. Of course, this
can only be applied to GPL programs, unless user buy a commercial license of
Cygwin (see http://www.redhat.com/software/cygwin/ ).

Another way would be to stop using tricks like “-Dmain=SDL_main” in SDL. I guess
you did it this way to be assured that SDL is the first to parse command-line.
But I think there is a real drawbacks in this approach (appart from our
problem) : a program can not be linked with several libraries that use this
main redefinition. It may lead to a developper having to choose between SDL and
another lib.

IMHO, this should be removed and it should be software author responsibility to
call a “SDL_ParseCommandLine(int argc, char **argv)” at the beginning of his
code. Of course this would be incompatible with current software. I think this
could be solved by letting the current scheme as default and by adding a new
autoconf macro that would pass an additionnal parameter to sdl-config, letting
it knows that it should not enforce the above flags.

Thanks a lot for reading. I’m looking forward for any comment/help.

Best regards,

Xavier

[excellent post snipped]

Thanks a lot for reading. I’m looking forward for any comment/help.

I would be interested in a patch that allowed building SDL as a cygwin
library. The reason that’s disabled by default is that most applications
built with SDL can be native applications without the overhead and requirements
of the cygwin layer.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment