Android NDK libjpeg windows 編譯

下載  http://www.ijg.org/files/jpegsr9a.zip

解壓縮

在解壓後的文件夾內 新建 buil.bat 文件,內容:

set PATH=%PATH%;E:\ndk\android-ndk-r10e
 
ndk-build.cmd NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk
pause

set PATH=%PATH%;E:\ndk\android-ndk-r10e
 這個是設置 ndk 目錄;

 

在解壓後的文件夾內 新建 Application.mk 內容:

APP_MODULES      := libjpeg
APP_OUT  := out
APP_ARCH := arm

NDK_TOOLCHAIN_VERSION := 4.9#(4.6 4.8 4.9)
APP_BUILD_SCRIPT := Android.mk
APP_ABI          := armeabi-v7a#(32_bit(armeabi armeabi-v7a x86 mips), 64_bit(arm64-v8a x86_64 mips64))
APP_PLATFORM     := android-19# "5.0" (3~21)
APP_STL          := c++_static#(system stlport_static stlport_shared gnustl_static gnustl_shared \
                                   gabi++_static gabi++_shared c++_static c++_shared)
APP_OPTIM        := release#(release debug)
APP_PIE          := true
APP_CPPFLAGS := -fexceptions -frtti -pie -fPIE

在解壓後的文件夾內 新建 Android.mk 內容:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \
        jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \
        jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \
        jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \
        jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \
        jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \
        jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \
        jquant2.c jutils.c jmemmgr.c jmemnobs.c
	LOCAL_C_INCLUDES := $(LOCAL_PATH) 
	LOCAL_CFLAGS += -g -O2 -fPIC -std=c99\
	-DANDROID -DANDROID_TILE_BASED_DECODE -DENABLE_ANDROID_NULL_CONVERT
	LOCAL_MODULE := libjpeg 
	LOCAL_MODULE_TAGS := optional 
 
 # unbundled branch, built against NDK. 
	#LOCAL_SDK_VERSION := 22 
	include $(BUILD_STATIC_LIBRARY)
	#include $(BUILD_SHARED_LIBRARY)

雙擊 build.bat 生成 obj 文件夾,內含有 .a 文件。

使用時注意:

這裏我發現它的頭文件和linux 生成的頭文件有不同,如果用相同的頭文件android 會崩潰。具體原因沒有找

偷懶用宏處理了一下都可以用:

/* jconfig.h.  Generated from jconfig.cfg by configure.  */
/* jconfig.cfg.  Generated from configure.ac by autoheader.  */

/* Characters are unsigned */
/* #undef CHAR_IS_UNSIGNED */

/* Maximum data space library will allocate. */
/* #undef DEFAULT_MAX_MEM */

/* Don't open files in binary mode. */
/* #undef DONT_USE_B_MODE */
#if defined(LINUX)
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Compiler supports function prototypes. */
#define HAVE_PROTOTYPES 1

/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Compiler supports 'unsigned char'. */
#define HAVE_UNSIGNED_CHAR 1

/* Compiler supports 'unsigned short'. */
#define HAVE_UNSIGNED_SHORT 1

/* Compiler does not support pointers to unspecified
 structures. */
/* #undef INCOMPLETE_TYPES_BROKEN */

/* How to obtain function inlining. */
#define INLINE __inline__

/* Define to the sub-directory in which libtool stores uninstalled libraries.
   */
#define LT_OBJDIR ".libs/"

/* Compiler has <strings.h> rather than standard <string.h>. */
/* #undef NEED_BSD_STRINGS */

/* Linker requires that global names be unique in
 first 15 characters. */
/* #undef NEED_SHORT_EXTERNAL_NAMES */

/* Need signal handler to clean up temporary files. */
/* #undef NEED_SIGNAL_CATCHER */

/* Need to include <sys/types.h> in order to obtain size_t. */
/* #undef NEED_SYS_TYPES_H */

/* The mktemp() function is not available. */
/* #undef NO_MKTEMP */

/* Name of package */
#define PACKAGE "libjpeg"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME "libjpeg"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libjpeg 9.1.0"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libjpeg"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "9.1.0"

/* Broken compiler shifts signed values as an unsigned shift. */
/* #undef RIGHT_SHIFT_IS_UNSIGNED */

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION "9.1.0"
#else
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

/* Define 'void' as 'char' for archaic compilers
 that don't understand it. */
/* #undef void */
#define HAVE_PROTOTYPES
#define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT
/* #define void char */
/* #define const */
#undef CHAR_IS_UNSIGNED
#define HAVE_STDDEF_H
#define HAVE_STDLIB_H
#undef NEED_BSD_STRINGS
#undef NEED_SYS_TYPES_H
#undef NEED_FAR_POINTERS	/* we presume a 32-bit flat memory model */
#undef NEED_SHORT_EXTERNAL_NAMES
#undef INCOMPLETE_TYPES_BROKEN

/* Define "boolean" as unsigned char, not enum, per Windows custom */
#ifndef __RPCNDR_H__		/* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#ifndef FALSE			/* in case these macros already exist */
#define FALSE	0		/* values of boolean */
#endif
#ifndef TRUE
#define TRUE	1
#endif
#define HAVE_BOOLEAN		/* prevent jmorecfg.h from redefining it */


#ifdef JPEG_INTERNALS

#undef RIGHT_SHIFT_IS_UNSIGNED

#endif /* JPEG_INTERNALS */

#ifdef JPEG_CJPEG_DJPEG

#define BMP_SUPPORTED		/* BMP image file format */
#define GIF_SUPPORTED		/* GIF image file format */
#define PPM_SUPPORTED		/* PBMPLUS PPM/PGM image file format */
#undef RLE_SUPPORTED		/* Utah RLE image file format */
#define TARGA_SUPPORTED		/* Targa image file format */

#define TWO_FILE_COMMANDLINE	/* optional */
#define USE_SETMODE		/* Microsoft has setmode() */
#undef NEED_SIGNAL_CATCHER
#undef DONT_USE_B_MODE
#undef PROGRESS_REPORT		/* optional */

#endif /* JPEG_CJPEG_DJPEG */
#endif 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章