Android Local Video Player Development-SDL Compilation

Source: Internet
Author: User

In fact, android support is added in Versions later than 1.3. After the source code is downloaded, create a jni directory under the SDL directory, then copy the files and folders under the original SDL directory to the jni directory. In the jni directory, we will see an android. mk file. This is the compilation file officially compiled for us. Because mobile phones basically use arm compilers, I added LOCAL_ARM_MODE = arm in it, the module compilation uses the arm compiler for compilation. The specific content is as follows:
[Cpp] ###########################
#
# SDL shared library
#
###########################
 
Include $ (CLEAR_VARS)
 
LOCAL_MODULE: = SDL2
LOCAL_ARM_MODE = arm
LOCAL_C_INCLUDES: = $ (LOCAL_PATH)/include
 
LOCAL_SRC_FILES: = \
$ (Subst $ (LOCAL_PATH )/,,\
$ (Wildcard $ (LOCAL_PATH)/src/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/dummy/*. c )\
$ (LOCAL_PATH)/src/atomic/SDL_atomic.c \
$ (LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
$ (Wildcard $ (LOCAL_PATH)/src/core/android/*. cpp )\
$ (Wildcard $ (LOCAL_PATH)/src/cpuinfo/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/events/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/file/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/haptic/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/haptic/dummy/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/joystick/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/joystick/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/loadso/dlopen/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/power/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/power/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/render/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/render/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/stdlib/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/thread/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/thread/pthread/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/timer/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/timer/unix/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/video/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/video/android/*. c ))
 
LOCAL_CFLAGS + =-DGL_GLEXT_PROTOTYPES
LOCAL_LDLIBS: =-ldl-lglesv450cm-lGLESv2-llog
 
Include $ (BUILD_SHARED_LIBRARY)

###########################
#
# SDL shared library
#
###########################

Include $ (CLEAR_VARS)

LOCAL_MODULE: = SDL2
LOCAL_ARM_MODE = arm
LOCAL_C_INCLUDES: = $ (LOCAL_PATH)/include

LOCAL_SRC_FILES: = \
$ (Subst $ (LOCAL_PATH )/,,\
$ (Wildcard $ (LOCAL_PATH)/src/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/audio/dummy/*. c )\
$ (LOCAL_PATH)/src/atomic/SDL_atomic.c \
$ (LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
$ (Wildcard $ (LOCAL_PATH)/src/core/android/*. cpp )\
$ (Wildcard $ (LOCAL_PATH)/src/cpuinfo/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/events/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/file/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/haptic/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/haptic/dummy/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/joystick/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/joystick/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/loadso/dlopen/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/power/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/power/android/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/render/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/render/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/stdlib/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/thread/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/thread/pthread/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/timer/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/timer/unix/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/video/*. c )\
$ (Wildcard $ (LOCAL_PATH)/src/video/android/*. c ))

LOCAL_CFLAGS + =-DGL_GLEXT_PROTOTYPES
LOCAL_LDLIBS: =-ldl-lglesv450cm-lGLESv2-llog

Include $ (BUILD_SHARED_LIBRARY) 3. If you compile the file directly, the following error will be prompted:
[Cpp]/home/SDL/jni/src/core/android/SDL_android.cpp: 30: 21: fatal error: EGL/egl. h: No such file or directory

/Home/SDL/jni/src/core/android/SDL_android.cpp: 30: 21: fatal error: EGL/egl. h: No such file or directory
Check that The EGL support is later than Version 2.3, so we need to add platform support. Therefore, we need to create an Application. mk file under the jni directory to specify the compilation platform. The content is as follows:
[Cpp] APP_ABI: = armeabi
APP_PLATFORM: = android-9

APP_ABI: = armeabi
APP_PLATFORM: = android-9 4. Run ndk-build on the jni directory terminal to compile libSDL2.so. The compilation process is as follows:
[Cpp] root @ zhangjie:/home/SDL/jni # ndk-build
Compile arm: SDL2 <= SDL_assert.c
Compile arm: SDL2 <= SDL. c
Compile arm: SDL2 <= SDL_error.c
Compile arm: SDL2 <= SDL_fatal.c
Compile arm: SDL2 <= SDL_hints.c
Compile arm: SDL2 <= SDL_log.c
Compile arm: SDL2 <= SDL_audio.c
Compile arm: SDL2 <= SDL_audiocvt.c
Compile arm: SDL2 <= SDL_audiodev.c
Compile arm: SDL2 <= SDL_audiotypecvt.c
Compile arm: SDL2 <= SDL_mixer.c
Compile arm: SDL2 <= SDL_wave.c
Compile arm: SDL2 <= SDL_androidaudio.c
Compile arm: SDL2 <= SDL_dummyaudio.c
Compile arm: SDL2 <= SDL_atomic.c
Compile arm: SDL2 <= SDL_spinlock.c
Compile ++ arm: SDL2 <= SDL_android.cpp
Compile arm: SDL2 <= SDL_cpuinfo.c
Compile arm: SDL2 <= SDL_clipboardevents.c
Compile arm: SDL2 <= SDL_dropevents.c
Compile arm: SDL2 <= SDL_events.c
Compile arm: SDL2 <= SDL_gesture.c
Compile arm: SDL2 <= SDL_keyboard.c
Compile arm: SDL2 <= SDL_mouse.c
Compile arm: SDL2 <= SDL_quit.c
Compile arm: SDL2 <= SDL_touch.c
Compile arm: SDL2 <= sdl_w.wevents.c
Compile arm: SDL2 <= SDL_rwops.c
Compile arm: SDL2 <= SDL_haptic.c
Compile arm: SDL2 <= SDL_syshaptic.c
Compile arm: SDL2 <= SDL_gamecontroller.c
Compile arm: SDL2 <= SDL_joystick.c
Compile arm: SDL2 <= SDL_sysjoystick.c
Compile arm: SDL2 <= SDL_sysloadso.c
Compile arm: SDL2 <= SDL_power.c
Compile arm: SDL2 <= SDL_syspower.c
Compile arm: SDL2 <= SDL_render.c
Compile arm: SDL2 <= SDL_yuv_mmx.c
Compile arm: SDL2 <= SDL_yuv_sw.c
Compile arm: SDL2 <= SDL_render_d3d.c
Compile arm: SDL2 <= SDL_render_gles2.c
Compile arm: SDL2 <= SDL_shaders_gles2.c
Compile arm: SDL2 <= SDL_render_gles.c
Compile arm: SDL2 <= SDL_render_gl.c
Compile arm: SDL2 <= SDL_shaders_gl.c
Compile arm: SDL2 <= SDL_render_psp.c
Compile arm: SDL2 <= SDL_blendfillrect.c
Compile arm: SDL2 <= SDL_blendline.c
Compile arm: SDL2 <= SDL_blendpoint.c
Compile arm: SDL2 <= SDL_drawline.c
Compile arm: SDL2 <= SDL_drawpoint.c
Compile arm: SDL2 <= SDL_render_sw.c
Compile arm: SDL2 <= SDL_rotate.c
Compile arm: SDL2 <= SDL_getenv.c
Compile arm: SDL2 <= SDL_iconv.c
Compile arm: SDL2 <= SDL_malloc.c
Compile arm: SDL2 <= SDL_qsort.c
Compile arm: SDL2 <= SDL_stdlib.c
Compile arm: SDL2 <= SDL_string.c
Compile arm: SDL2 <= SDL_thread.c
Compile arm: SDL2 <= SDL_syscond.c
Compile arm: SDL2 <= SDL_sysmutex.c
Compile arm: SDL2 <= SDL_syssem.c
Compile arm: SDL2 <= sdl_javashread.c
Compile arm: SDL2 <= SDL_timer.c
Compile arm: SDL2 <= sdl_policimer.c
Compile arm: SDL2 <= SDL_blit_0.c
Compile arm: SDL2 <= SDL_blit_1.c
Compile arm: SDL2 <= SDL_blit_A.c
Compile arm: SDL2 <= SDL_blit_auto.c
Compile arm: SDL2 <= SDL_blit.c
Compile arm: SDL2 <= SDL_blit_copy.c
Compile arm: SDL2 <= SDL_blit_N.c
Compile arm: SDL2 <= SDL_blit_slow.c
Compile arm: SDL2 <= sdl_bmp .c
Compile arm: SDL2 <= SDL_clipboard.c
Compile arm: SDL2 <= SDL_fillrect.c
Compile arm: SDL2 <= SDL_pixels.c
Compile arm: SDL2 <= SDL_rect.c
Compile arm: SDL2 <= SDL_RLEaccel.c
Compile arm: SDL2 <= SDL_shape.c
Compile arm: SDL2 <= SDL_stretch.c
Compile arm: SDL2 <= SDL_surface.c
Compile arm: SDL2 <= SDL_video.c
Compile arm: SDL2 <= SDL_androidclipboard.c
Compile arm: SDL2 <= SDL_androidevents.c
Compile arm: SDL2 <= SDL_androidgl.c
Compile arm: SDL2 <= SDL_androidkeyboard.c
Compile arm: SDL2 <= SDL_androidtouch.c
Compile arm: SDL2 <= SDL_androidvideo.c
Compile arm: SDL2 <= sdl_android1_1_c
StaticLibrary: libstdc ++.
SharedLibrary: libSDL2.so
Install: libSDL2.so => libs/armeabi/libSDL2.so

Root @ zhangjie:/home/SDL/jni # ndk-build
Compile arm: SDL2 <= SDL_assert.c
Compile arm: SDL2 <= SDL. c
Compile arm: SDL2 <= SDL_error.c
Compile arm: SDL2 <= SDL_fatal.c
Compile arm: SDL2 <= SDL_hints.c
Compile arm: SDL2 <= SDL_log.c
Compile arm: SDL2 <= SDL_audio.c
Compile arm: SDL2 <= SDL_audiocvt.c
Compile arm: SDL2 <= SDL_audiodev.c
Compile arm: SDL2 <= SDL_audiotypecvt.c
Compile arm: SDL2 <= SDL_mixer.c
Compile arm: SDL2 <= SDL_wave.c
Compile arm: SDL2 <= SDL_androidaudio.c
Compile arm: SDL2 <= SDL_dummyaudio.c
Compile arm: SDL2 <= SDL_atomic.c
Compile arm: SDL2 <= SDL_spinlock.c
Compile ++ arm: SDL2 <= SDL_android.cpp
Compile arm: SDL2 <= SDL_cpuinfo.c
Compile arm: SDL2 <= SDL_clipboardevents.c
Compile arm: SDL2 <= SDL_dropevents.c
Compile arm: SDL2 <= SDL_events.c
Compile arm: SDL2 <= SDL_gesture.c
Compile arm: SDL2 <= SDL_keyboard.c
Compile arm: SDL2 <= SDL_mouse.c
Compile arm: SDL2 <= SDL_quit.c
Compile arm: SDL2 <= SDL_touch.c
Compile arm: SDL2 <= sdl_w.wevents.c
Compile arm: SDL2 <= SDL_rwops.c
Compile arm: SDL2 <= SDL_haptic.c
Compile arm: SDL2 <= SDL_syshaptic.c
Compile arm: SDL2 <= SDL_gamecontroller.c
Compile arm: SDL2 <= SDL_joystick.c
Compile arm: SDL2 <= SDL_sysjoystick.c
Compile arm: SDL2 <= SDL_sysloadso.c
Compile arm: SDL2 <= SDL_power.c
Compile arm: SDL2 <= SDL_syspower.c
Compile arm: SDL2 <= SDL_render.c
Compile arm: SDL2 <= SDL_yuv_mmx.c
Compile arm: SDL2 <= SDL_yuv_sw.c
Compile arm: SDL2 <= SDL_render_d3d.c
Compile arm: SDL2 <= SDL_render_gles2.c
Compile arm: SDL2 <= SDL_shaders_gles2.c
Compile arm: SDL2 <= SDL_render_gles.c
Compile arm: SDL2 <= SDL_render_gl.c
Compile arm: SDL2 <= SDL_shaders_gl.c
Compile arm: SDL2 <= SDL_render_psp.c
Compile arm: SDL2 <= SDL_blendfillrect.c
Compile arm: SDL2 <= SDL_blendline.c
Compile arm: SDL2 <= SDL_blendpoint.c
Compile arm: SDL2 <= SDL_drawline.c
Compile arm: SDL2 <= SDL_drawpoint.c
Compile arm: SDL2 <= SDL_render_sw.c
Compile arm: SDL2 <= SDL_rotate.c
Compile arm: SDL2 <= SDL_getenv.c
Compile arm: SDL2 <= SDL_iconv.c
Compile arm: SDL2 <= SDL_malloc.c
Compile arm: SDL2 <= SDL_qsort.c
Compile arm: SDL2 <= SDL_stdlib.c
Compile arm: SDL2 <= SDL_string.c
Compile arm: SDL2 <= SDL_thread.c
Compile arm: SDL2 <= SDL_syscond.c
Compile arm: SDL2 <= SDL_sysmutex.c
Compile arm: SDL2 <= SDL_syssem.c
Compile arm: SDL2 <= sdl_javashread.c
Compile arm: SDL2 <= SDL_timer.c
Compile arm: SDL2 <= sdl_policimer.c
Compile arm: SDL2 <= SDL_blit_0.c
Compile arm: SDL2 <= SDL_blit_1.c
Compile arm: SDL2 <= SDL_blit_A.c
Compile arm: SDL2 <= SDL_blit_auto.c
Compile arm: SDL2 <= SDL_blit.c
Compile arm: SDL2 <= SDL_blit_copy.c
Compile arm: SDL2 <= SDL_blit_N.c
Compile arm: SDL2 <= SDL_blit_slow.c
Compile arm: SDL2 <= sdl_bmp .c
Compile arm: SDL2 <= SDL_clipboard.c
Compile arm: SDL2 <= SDL_fillrect.c
Compile arm: SDL2 <= SDL_pixels.c
Compile arm: SDL2 <= SDL_rect.c
Compile arm: SDL2 <= SDL_RLEaccel.c
Compile arm: SDL2 <= SDL_shape.c
Compile arm: SDL2 <= SDL_stretch.c
Compile arm: SDL2 <= SDL_surface.c
Compile arm: SDL2 <= SDL_video.c
Compile arm: SDL2 <= SDL_androidclipboard.c
Compile arm: SDL2 <= SDL_androidevents.c
Compile arm: SDL2 <= SDL_androidgl.c
Compile arm: SDL2 <= SDL_androidkeyboard.c
Compile arm: SDL2 <= SDL_androidtouch.c
Compile arm: SDL2 <= SDL_androidvideo.c
Compile arm: SDL2 <= sdl_android1_1_c
StaticLibrary: libstdc ++.
SharedLibrary: libSDL2.so
Install: libSDL2.so => libs/armeabi/libSDL2.so
After compiling the sdl library, we can call its related functions to implement our functions.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.