Android.mk
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 9054 18d34edc79ac
child 9592 ba866f4ec675
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 LOCAL_PATH := $(call my-dir)
     2 
     3 ###########################
     4 #
     5 # SDL shared library
     6 #
     7 ###########################
     8 
     9 include $(CLEAR_VARS)
    10 
    11 LOCAL_MODULE := SDL2
    12 
    13 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
    14 
    15 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
    16 
    17 LOCAL_SRC_FILES := \
    18 	$(subst $(LOCAL_PATH)/,, \
    19 	$(wildcard $(LOCAL_PATH)/src/*.c) \
    20 	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
    21 	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
    22 	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
    23 	$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
    24 	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
    25 	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
    26 	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
    27 	$(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
    28 	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
    29 	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
    30 	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
    31 	$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
    32 	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
    33 	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
    34 	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
    35 	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
    36 	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
    37 	$(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
    38 	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
    39 	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
    40 	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
    41 	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
    42 	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
    43 	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
    44 	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
    45 	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
    46 	$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
    47     $(wildcard $(LOCAL_PATH)/src/test/*.c))
    48 
    49 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
    50 LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
    51 
    52 include $(BUILD_SHARED_LIBRARY)
    53 
    54 ###########################
    55 #
    56 # SDL static library
    57 #
    58 ###########################
    59 
    60 LOCAL_MODULE := SDL2_static
    61 
    62 LOCAL_MODULE_FILENAME := libSDL2
    63 
    64 LOCAL_SRC_FILES += $(subst $(LOCAL_PATH)/,,$(LOCAL_PATH)/src/main/android/SDL_android_main.c)
    65 
    66 LOCAL_LDLIBS := 
    67 LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
    68 
    69 include $(BUILD_STATIC_LIBRARY)