Refer to the following 2 articles and make a small change.
Http://recursify.com/blog/2013/05/25/building-freeimage-for-android
Http://blog.sina.com.cn/s/blog_4119bd830100w7ov.html
1. Download The source code of Freeimage 3.15.4 from the official website http://freeimage.sourceforge.net/download.html
2. New Android Project ADD Native Support
Copy the source directory and Makefile.srcs under the Freeimage directory to the JNI root directory
3. Modify Android.mk to
[CPP]View Plaincopy
- Local_path: = $ (call My-dir)
- Include $ (local_path)/makefile.srcs
- Include $ (clear_vars)
- Local_module: = freeimagestatic
- Local_c_includes: = $ (local_path)/source \
- $ (local_path)/source/metadata \
- $ (local_path)/source/freeimagetoolkit \
- $ (local_path)/source/libjpeg \
- $ (local_path)/source/libpng \
- $ (local_path)/source/libtiff4 \
- $ (local_path)/source/zlib \
- $ (local_path)/source/libopenjpeg \
- $ (local_path)/SOURCE/OPENEXR \
- $ (local_path)/source/openexr/half \
- $ (local_path)/SOURCE/OPENEXR/IEX \
- $ (local_path)/SOURCE/OPENEXR/ILMIMF \
- $ (local_path)/source/openexr/ilmthread \
- $ (local_path)/source/openexr/imath \
- $ (local_path)/source/librawlite \
- $ (local_path)/source/librawlite/dcraw \
- $ (local_path)/source/librawlite/internal \
- $ (local_path)/source/librawlite/libraw \
- $ (Local_path)/source/librawlite/src
- Local_src_files: = $ (SRCS)
- Local_cpp_features: = Rtti Exceptions
- #LOCAL_CFLAGS: =-o3-fpic
- Include $ (build_static_library)
- Include $ (clear_vars)
- Local_module: = Freeimage
- Local_static_libraries: = freeimagestatic
- Include $ (build_shared_library)
4. Modify APPLICATION.MK for full platform compilation
[CPP]View Plaincopy
- App_stl: = gnustl_static
- App_abi: = All
- App_optim: = Release
Or just arm's.
[CPP]View Plaincopy
- ndk_toolchain_version:=4.8
- App_stl: = gnustl_static
- App_cppflags: =-std=c++11
- App_abi: = Armeabi
5. Find Libtiff4/tif_config.h Comment out
[CPP]View Plaincopy
- #define HAVE_SEARCH_H 1
6. Because the compilation will not find the librawlite\internal\dcraw_common.cpp top add swab function
- #include <stdint.h>
- #include <asm/byteorder.h>
- static void swab (const void *from, void *to, ssize_t n)
- {
- ssize_t i;
- if (n < 0)
- {
- return;
- }
- For (i = 0; i < (N/2) * 2; i + = 2)
- {
- * ((uint16_t*) to + i) = __arch__swab16 (* ((uint16_t*) from + i));
- }
- }
OpenEXR a little bit of compatibility bug
The workaround is to find ImfHuf.cpp to modify the order in which the head file is contained
- #include <string.h>
- #include <cstring>
- #include <algorithm>
- #include <imfhuf.h>
- #include <imfint64.h>
- #include <imfautoarray.h>
- #include "Iex.h" &NBSP;&NBSP;
- #include <assert.h>
8. Compiling
NDK compilation Freeimage