编译Android版本的libmad


1、 下载libmad源码

2、 在目录C:\cygwin\home\Administrator\Android-ndk-r4b-windows\android-ndk-r4b\samples\下创建目录jni,并把libmad的源码解压到该目录下,这样mad.h的目录是:C:\cygwin\home\Administrator\android-ndk-r4b-windows\android-ndk-r4b\samples\libmad\jni\libmad-0.15.1b

3、 在jni目录下建立Android.mk内容:

include$(all-subdir-makefiles)

4、 在jni/libmad-0.15.1b目录下建立Android.mk,内容:

LOCAL_PATH := $(call my-dir)

 

include $(CLEAR_VARS)

 

LOCAL_MODULE := mad

LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := bit.c decoder.c fixed.c frame.c huffman.c layer12.clayer3.c stream.c synth.c timer.c version.c

LOCAL_CFLAGS := -DHAVE_CONFIG_H -DFPM_ARM -ffast-math -O3

 

include $(BUILD_SHARED_LIBRARY)

5、 启动Cygwin,到目录samples下

6、 执行:../ndk-build NDK_PROJECT_PATH=$NDK_ROOT/samples/libmad


注意:这里使用的config.h不是执行configure生成的,而是从网上down的一个,内容是:

  1. /* config.h.  Generated by configure.  */  
  2. /* config.h.in.  Generated from configure.ac by autoheader.  */  
  3.   
  4. /* Define to enable diagnostic debugging support. */  
  5. /* #undef DEBUG */  
  6.   
  7. /* Define to enable experimental code. */  
  8. /* #undef EXPERIMENTAL */  
  9.   
  10. /* Define to 1 if you have the <assert.h> header file. */  
  11. #define HAVE_ASSERT_H 1   
  12.   
  13. /* Define to 1 if you have the <dlfcn.h> header file. */  
  14. #define HAVE_DLFCN_H 1   
  15.   
  16. /* Define to 1 if you have the <errno.h> header file. */  
  17. #define HAVE_ERRNO_H 1   
  18.   
  19. /* Define to 1 if you have the `fcntl' function. */  
  20. #define HAVE_FCNTL 1   
  21.   
  22. /* Define to 1 if you have the <fcntl.h> header file. */  
  23. #define HAVE_FCNTL_H 1   
  24.   
  25. /* Define to 1 if you have the `fork' function. */  
  26. #define HAVE_FORK 1   
  27.   
  28. /* Define to 1 if you have the <inttypes.h> header file. */  
  29. #define HAVE_INTTYPES_H 1   
  30.   
  31. /* Define to 1 if you have the <limits.h> header file. */  
  32. #define HAVE_LIMITS_H 1   
  33.   
  34. /* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */  
  35. /* #undef HAVE_MADD16_ASM */  
  36.   
  37. /* Define if your MIPS CPU supports a 2-operand MADD instruction. */  
  38. /* #undef HAVE_MADD_ASM */  
  39.   
  40. /* Define to 1 if you have the <memory.h> header file. */  
  41. #define HAVE_MEMORY_H 1   
  42.   
  43. /* Define to 1 if you have the `pipe' function. */  
  44. #define HAVE_PIPE 1   
  45.   
  46. /* Define to 1 if you have the <stdint.h> header file. */  
  47. #define HAVE_STDINT_H 1   
  48.   
  49. /* Define to 1 if you have the <stdlib.h> header file. */  
  50. #define HAVE_STDLIB_H 1   
  51.   
  52. /* Define to 1 if you have the <strings.h> header file. */  
  53. #define HAVE_STRINGS_H 1   
  54.   
  55. /* Define to 1 if you have the <string.h> header file. */  
  56. #define HAVE_STRING_H 1   
  57.   
  58. /* Define to 1 if you have the <sys/stat.h> header file. */  
  59. #define HAVE_SYS_STAT_H 1   
  60.   
  61. /* Define to 1 if you have the <sys/types.h> header file. */  
  62. #define HAVE_SYS_TYPES_H 1   
  63.   
  64. /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */  
  65. #define HAVE_SYS_WAIT_H 1   
  66.   
  67. /* Define to 1 if you have the <unistd.h> header file. */  
  68. #define HAVE_UNISTD_H 1   
  69.   
  70. /* Define to 1 if you have the `waitpid' function. */  
  71. #define HAVE_WAITPID 1   
  72.   
  73. /* Define to disable debugging assertions. */  
  74. /* #undef NDEBUG */  
  75.   
  76. /* Define to optimize for accuracy over speed. */  
  77. /* #undef OPT_ACCURACY */  
  78.   
  79. /* Define to optimize for speed over accuracy. */  
  80. #define OPT_SPEED 1   
  81.   
  82. /* Define to enable a fast subband synthesis approximation optimization. */  
  83. /* #undef OPT_SSO */  
  84.   
  85. /* Define to influence a strict interpretation of the ISO/IEC standards, even 
  86.    if this is in opposition with best accepted practices. */  
  87. /* #undef OPT_STRICT */  
  88.   
  89. /* Name of package */  
  90. #define PACKAGE "libmad"   
  91.   
  92. /* Define to the address where bug reports for this package should be sent. */  
  93. #define PACKAGE_BUGREPORT "support@underbit.com"   
  94.   
  95. /* Define to the full name of this package. */  
  96. #define PACKAGE_NAME "MPEG Audio Decoder"   
  97.   
  98. /* Define to the full name and version of this package. */  
  99. #define PACKAGE_STRING "MPEG Audio Decoder 0.15.1b"   
  100.   
  101. /* Define to the one symbol short name of this package. */  
  102. #define PACKAGE_TARNAME "libmad"   
  103.   
  104. /* Define to the version of this package. */  
  105. #define PACKAGE_VERSION "0.15.1b"   
  106.   
  107. /* The size of a `int', as computed by sizeof. */  
  108. #define SIZEOF_INT 4   
  109.   
  110. /* The size of a `long', as computed by sizeof. */  
  111. #define SIZEOF_LONG 4   
  112.   
  113. /* The size of a `long long', as computed by sizeof. */  
  114. #define SIZEOF_LONG_LONG 8   
  115.   
  116. /* Define to 1 if you have the ANSI C header files. */  
  117. #define STDC_HEADERS 1   
  118.   
  119. /* Version number of package */  
  120. #define VERSION "0.15.1b"   
  121.   
  122. /* Define to 1 if your processor stores words with the most significant byte 
  123.    first (like Motorola and SPARC, unlike Intel and VAX). */  
  124. /* #undef WORDS_BIGENDIAN */  
  125.   
  126. /* Define to empty if `const' does not conform to ANSI C. */  
  127. /* #undef const */  
  128.   
  129. /* Define to `__inline__' or `__inline' if that's what the C compiler 
  130.    calls it, or to nothing if 'inline' is not supported under any name.  */  
  131. #ifndef __cplusplus   
  132. /* #undef inline */  
  133. #endif   
  134.   
  135. /* Define to `int' if <sys/types.h> does not define. */  
  136. /* #undef pid_t */  

相关内容