Hi,
I have a small program based on SDL2.0 and it works fine on both linux and
windows. I tried to port it to Android on Linuxmint, but some problems
appeared.
I downloaded SDL2.0 and followed its instructions put my program into
project/jni/src. (Actually, my program only contains one YourSourceHere.c
file) I copied the SDL folder to project/jni/. Then I found SDL folder is
not enough. In that program, I used SDL_image to load images and SDL_ttf to
render text. So I put SDL_image folder and SDL_ttf folder into project/jni/
– they both have Android.mk file in them.
But after I ran ndk-build, error messages appeared.
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:34:21:
error: jpeglib.h: No such file or directory
…
Seemed like SDL_image cannot find the include files of libjpeg-8d.
I noticed in Android.mk of SDL_image that it would link png and jpeg libs
as static libraries. So I downloaded JPEG v8d and libpng 1.5.7 from their
sites since the packages from
http://www.libsdl.org/projects/SDL_image/were for windows. I extracted
the files and used “./configure” and “make”.
When all the header files SDL_image needed were available, I got new errors:
/home/adolfans/my_android_project/android-project/obj/local/armeabi/objs/SDL_image/IMG_jpg.o:
In function `IMG_InitJPG’:
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_calc_output_dimensions’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_CreateDecompress’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_destroy_decompress’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_finish_decompress’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_read_header’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_read_scanlines’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_resync_to_restart’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_start_decompress’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_jpg.c:165:
undefined reference to `jpeg_std_error’
/home/adolfans/my_android_project/android-project/obj/local/armeabi/objs/SDL_image/IMG_png.o:
In function `IMG_InitPNG’:
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_create_info_struct’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_create_read_struct’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_destroy_read_struct’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_IHDR’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_channels’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_io_ptr’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_PLTE’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_tRNS’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_get_valid’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_read_image’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_read_info’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_read_update_info’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_expand’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_gray_to_rgb’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_packing’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_read_fn’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_strip_16’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_sig_cmp’
/home/adolfans/my_android_project/android-project/jni/SDL_image-1.2.12/IMG_png.c:291:
undefined reference to `png_set_longjmp_fn’
collect2: ld returned 1 exit status
make: ***
[/home/adolfans/my_android_project/android-project/obj/local/armeabi/libSDL_image.so]
error 1
I’ve searched everywhere and didn’t found any instruction on how to compile
SDL_image with SDL2.0 or SDL1.3 for android. Even the README file of
SDL_image didn’t provide any information on that.
I wonder if SDL_image for android is really available…
If it is available, how to solve these problems? Have I done something
wrong?
BTW, I’m still learning English. I don’t know if I have expressed clearly.
If not, I’ll say sorry for my English.
Anyway, thanks in advance!!!
-Adolfans