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 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

恋恋西风

up up up

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值