premake/README-linux.txt
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 7925 f090a47eb7f7
permissions -rwxr-xr-x
Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead

Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
     1 You may generate GNU makefiles for building SDL2 and its related test suite by
     2 using the gmake shell script in the Linux/build-scripts folder.
     3 
     4 Linux support is currently experimental for the meta-build system. Most of the
     5 progress made on this support happened toward the end of the meta-build system
     6 project, so there is a lot currently missing that could be added in the future.
     7 For the most part, the Linux support works well, but there is a significant
     8 amount of testing needed to verify it can be built in many different
     9 environments.
    10 
    11 The Linux project does not target every dependency it should (as seen in the
    12 autotools configure script or in the CMake script), but it does target the
    13 following dependencies:
    14 
    15   -D-Bus (required to build Linux at all)
    16   -DLOpen (most of the other dependencies are dependent on this)
    17   -ALSA
    18   -PulseAudio
    19   -ESD
    20   -NAS
    21   -OSS
    22   -X11
    23   -OpenGL
    24 
    25 Also, the Linux system should be building the SDL2 library as a shared library,
    26 but it builds it as a static library because of a few premake-related issues.
    27 This is because when the makefile generated by premake tells the linker where to
    28 find the definitions library (libSDL2.o), it also gives a hint to the loader to
    29 find libSDL2.so in the same place, with a relative path. This means in order to
    30 execute the program dynamically linked to SDL2, it's looking in some path like:
    31 
    32   "../../SDL2/Build/Debug"
    33 
    34 Now, while this path works at the location of the makefile (such as
    35 ./tests/testsprite), it does not make sense from the actual location of the
    36 executable (./tests/testsprite/Build/Debug). Furthermore, it's just massively
    37 inconvenient to have a relative path to look for the shared object. Moving
    38 libSDL2.so into the same directory as the executable does not solve this issue.
    39 Unfortunately, premake also does not allow an install target to be created for
    40 the makefiles, which is another one of the major issues related to building SDL2
    41 as a shared library on Linux. Once these problems are solved, this support
    42 should be very straightforward to add to this system in the future.
    43 
    44 The Linux system does have both an automated test and cleaning shell files for
    45 running through the entire supported test suite and cleaning up the generated
    46 and built files, respectively.