• Show log

    Commit

  • Hash : a329c7f1
    Author : Sam Lantinga
    Date : 2013-10-18T00:13:51

    Fixed bug 2139 - SDL_CreateWindow/WIN_GL_LoadLibrary fails due to external iconv not being able to convert path J?nis R?cis Brief history: We recently ported a game from SDL 1.2 to SDL 2. While doing Windows testing, I soon discovered that the game exits without opening a window with my cross-compiled SDL2.dll, but works great with the SDL2.dll from the MinGW SDK on libsdl.org. It was as simple as swapping out the DLLs to make it work. Running the game in Wine showed that the game actually does run, up until the call to SDL_CreateWindow, which fails and leads the game to print out an error: Failure to create window (LoadLibrary("OPENGL32.DLL"): (null)) Which basically says that there was no error, but maybe that's a Wine quirk. The error string originates in SDL_windowsopengl.c, in WIN_GL_LoadLibrary, which contains this piece of code: wpath = WIN_UTF8ToString(path); _this->gl_config.dll_handle = LoadLibrary(wpath); SDL_free(wpath); if (!_this->gl_config.dll_handle) { char message[1024]; SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", path); return WIN_SetError(message); } After some digging, I discovered the culprit: WIN_UTF8ToString returns NULL. Why? Because it calls iconv_open from an iconv.dll that does not support the UCS-2-INTERNAL encoding. Why does the official SDL2.dll work? Because it calls no external iconv functions at all. It turns out that the Fedora MinGW infrastructure (from which I obtained the conventiently prebuilt iconv.dll) does not provide a DLL from libiconv, but instead provides a DLL from a minimal Windows library called win-iconv. Which knows a good bit, but doesn't know anything about UCS-2-INTERNAL: http://code.google.com/p/win-iconv/source/browse/trunk/win_iconv.c#155 So there are two problems here: 1) The error message is clearly useless, because LoadLibrary is an innocent bystander. Instead wpath should probably checked for NULL, and a more appropriate error should be set. Ideally something that makes it clear than an external iconv is causing trouble. 2) SDL doomed itself at the ./configure step, by finding an existing iconv and happily using it without confirming support for the mandatory encodings required by SDL. There are certainly a few easy ways out of the situation (although I didn't yet manage to figure out how to prevent ./configure from looking for external iconv), but this had me completely stomped for a good while, so I figured it's worth writing down if anything. (Search also found this, which talks a little about using UTF-16LE instead of UCS-2-INTERNAL: https://bugzilla.libsdl.org/show_bug.cgi?id=2075)

  • Properties

  • Git HTTP https://git.kmx.io/kc3-lang/SDL.git
    Git SSH git@git.kmx.io:kc3-lang/SDL.git
    Public access ? public
    Description

    Fork of https://github.com/libsdl-org/SDL

    Users
    thodg_w thodg_m thodg_l kc3_lang_org thodg www_kmx_io
    Tags

  • README.txt

  •                          Simple DirectMedia Layer
    
                                      (SDL)
    
                                    Version 2.0
    
    ---
    http://www.libsdl.org/
    
    Simple DirectMedia Layer is a cross-platform development library designed
    to provide low level access to audio, keyboard, mouse, joystick, and graphics
    hardware via OpenGL and Direct3D. It is used by video playback software,
    emulators, and popular games including Valve's award winning catalog
    and many Humble Bundle games.
    
    SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
    Support for other platforms may be found in the source code.
    
    SDL is written in C, works natively with C++, and there are bindings 
    available for several other languages, including C# and Python.
    
    This library is distributed under the zlib license, which can be found
    in the file "COPYING.txt".
    
    The best way to learn how to use SDL is to check out the header files in
    the "include" subdirectory and the programs in the "test" subdirectory.
    The header files and test programs are well commented and always up to date.
    More documentation and FAQs are available online at:
    	http://wiki.libsdl.org/
    
    If you need help with the library, or just want to discuss SDL related
    issues, you can join the developers mailing list:
    	http://www.libsdl.org/mailing-list.php
    
    Enjoy!
    	Sam Lantinga				(slouken@libsdl.org)