SDL and jpeglib on pocket pc runtime error


I am trying to add jpg file support to pocket pc application but got stuck on a
runtime error. Everything else works fine, like loading BMP, GIF, drawing
graphics on screen, I/O, etc.

Using a debugger, I am running my application step by step and application
terminates without an error message.
SDL_Image: IMG_jpg.c: SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src):
right before the IMG_LoadJPG_RW function scope end, application terminates after
running return(surface); statement.

Here are my specs:
IDE: VS2008,
Platform: Windows Mobile 5.0 Pocket PC SDK(ARMV4I)
JpegLib 6b

All projects:

  • Configurations are set to WM5.0 platform,
  • C/C++ -> Advanced -> Compile for Architecture: ARM4 (/QRarch4)
  • Linker -> Advanced -> Target Machine: Not Set

This looks really bad and any help is highly appreciated.

Ok I got it!

I was importing secchk.lib to my binary. I traced it on assembly.
It turned out that, security_check_something function call was
failing somehow, for the last return statement.

I used /GS- compiler option to disable Buffer Security Check
and it solved my problem.