I'm trying to build SDL_perl 2.1.3 on Win32 using MinGW. A custom-built Perl is installed under E:\perl-5.8.7, and the important MinGW files are under E:\msys\1.0\mingw. SDL itself was compiled, along with the supporting libs required by SDL_perl (SDL_mixer, SDL_image, etc.) are also built at that location.
Since SDL was built under MSYS, the paths that sdl-config points to are inside the MinGW system. The normal sdl-config output is:
$ sdl-config --libs -L/mingw/lib -lmingw32 -lSDLmain -lSDL -mwindows $ sdl-config --cflags -I/mingw/include/SDL -Dmain=SDL_main
Within the Build.PL, there are two variables that hold the compiler and linker flags, respectively, which normally hold the output from sdl-config. I've modified these like this:
my $sdl_compile_flags = '-O2 -Ie:\msys\1.0\mingw\include\SDL -Dmain=SD +L_main'; my $sdl_link_flags = '-O2 -Ie:\msys\1.0\mingw\include\SDL -Dmain=SD +L_main '. '-LE:\msys\1.0\mingw\lib -lmingw32 -lSDLmain -lSDL';
I have also compiled a working SDL program from a tutorial (the zip file for the code is available at http://gpwiki.org/index.php/Files:SDL_PlaySound.zip). After a lot of playing with the flags, I found that this works:
gcc -O2 -IE:\msys\1.0\mingw\include\SDL -Dmain=SDL_main -c SDL_PlaySou +nd.c gcc -O2 -IE:\msys\1.0\mingw\include\SDL -Dmain=SDL_main -o SDL_PlaySou +nd.exe SDL_PlaySound.o -LE:\msys\1.0\mingw\lib -lmingw32 -lSDLmain -l +SDL -lSDL_mixer -mwindows
It seems to be very sensitive to the ordering of the flags, or else you get errors about missing symbols in the linking step (much like the errors below).
The SDL_perl build compiles the program like this:
e:\perl-5.8.7\bin\perl.exe "-Ie:\perl-5.8.7\lib" "-Ie:\perl-5.8.7\lib" + "E:\perl-5.8.7\lib\ExtUtils\xsubpp" -noprototypes -typemap "E:\perl- +5.8.7\lib\ExtUtils\typemap" "src\SDL_perl.xs"gcc -c -s -O2 -DWIN32 -D +HAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-stri +ct-aliasing -DPERL_MSVCRT_READFIX -s -O2 -I"E:\perl-5.8.7\lib\CORE" - +I"E:\msys\1.0\mingw\include" -o "src\SDL_perl.o" "src\SDL_perl.c"
Which seems to work, but then the linking step goes like this:
dlltool --def "src\SDL_perl.def" --output-exp "blib\arch\auto\SDL_perl +\SDL_perl.exp" g++ -o "blib\arch\auto\SDL_perl\SDL_perl.dll" -Wl,--base-file,"src\SDL +_perl.base" -Wl,--image-base,0x23210000 -mdll -s -Le:\perl-5.8.7\lib\ +CORE -Le:\msys\1.0\mingw\lib -O2 -Ie:\msys\1.0\mingw\include\SDL -Dma +in=SDL_main -LE:\msys\1.0\mingw\lib -lmingw32 -lSDLmain -lSDL "src\SD +L_perl.lds" "blib\arch\auto\SDL_perl\SDL_perl.exp"
(Note that Perl on MinGW compiles using gcc, but links using g++, and therefore all Perl modules that include C code also link using g++. No, I don't know why.)
The 'dlltool' part seems to work fine, but the g++ linking command gives the following errors:
src\SDL_perl.o(.text+0x52f):SDL_perl.c: undefined reference to `SDL_Ge +tError' src\SDL_perl.o(.text+0x6e4):SDL_perl.c: undefined reference to `SDL_In +it' src\SDL_perl.o(.text+0x8c4):SDL_perl.c: undefined reference to `SDL_In +itSubSystem' src\SDL_perl.o(.text+0xa48):SDL_perl.c: undefined reference to `SDL_Qu +itSubSystem' [ About 40 other errors along the same lines ]
So that's where I'm stuck, with my caffeine-overdosed and sleep-deprived brain having run out of ideas.
Update: Changed title to specify the build environment.
Update 2: I've been playing with the linking command a little more. I'm now using this:
g++ -Wl,--base-file,"src\SDL_perl.base" -Wl,--image-base,0x23210000 -s + -O2 -o "blib\arch\auto\SDL_perl\SDL_perl.dll" "src\SDL_perl.lds" "bl +ib\arch\auto\SDL_perl\SDL_perl.exp" -Le:\perl-5.8.7\lib\CORE -LE:\msy +s\1.0\mingw\lib -lmingw32 -lSDLmain -lSDL -mdll
Thus putting the libraries being linked to after the files being linked, which is basically what is done in the SDL_PlaySound program noted above. This gets the errors down to just:
blib\arch\auto\SDL_perl\SDL_perl.exp(.edata+0x50):fake: undefined refe +rence to `boot_' blib\arch\auto\SDL_perl\SDL_perl.exp(.edata+0x54):fake: undefined refe +rence to `boot_' collect2: ld returned 1 exit status
Which is better than before, anyway. Even if this leads to a working command, I'm still not sure how to coerce Module::Build into producing such a command, since its build/link flags are always placed before the linked files. Although there aren't that many files to compile/link in this program, so I could do it by hand.
Update 3: This works:
g++ -Wl,--base-file,"src\SDL_perl.base" -Wl,--image-base,0x23210000 -s + -O2 -o "blib\arch\auto\SDL_perl\SDL_perl.dll" "src\SDL_perl.lds" "bl +ib\arch\auto\SDL_perl\SDL_perl.exp" -Le:\perl-5.8.7\lib\CORE -LE:\msy +s\1.0\mingw\lib -lperl58 -lmingw32 -lSDLmain -lSDL -mdll
Thanks to Perl Monks for being a Cardboard Programmer :)
Now, how to get Module::Build to output that command?
Update 42: Broke again. Don't know what happened. Need sleep.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
In reply to SDL_perl Building Errors on Win32/MinGW by hardburn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |