I'm new to NDK and JNI and not sure how to fix this error. I manually copy libMathFuncLib.so, mathFuncsLibs.cpp and MathFuncLibs.h files to Eclipse project. When I run this command 'ndk-build' and I get back 'workspace/test/jni/TestMath.cpp: error: 'Add' was not declared in this scope.'
Here is my folder structure:
-test
|__src
|__ExecuteTest.java
|__MainActivity.java
|__jni
|__Android.mk
|__Application.mk
|__TestMath.cpp
|__libs
|__armeabi
|__myLibs
|__armeabi
|__libMathFuncLib.so
|__myNatives
|__MathFuncLibs.cpp
|__MathFuncLib.h
Here is MathFuncLib.h file:
//This is static library example
#ifndef MathFuncLib_INCLUDED
#define MathFuncLib_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
class MyMathFunc
{
public:
static int Add(int a, int b);
static int Subtract(int a, int b);
static int Multiply(int a, int b);
static double Divide(int a, int b);
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif
Here is MathFuncLib.cpp file:
#include "MathFuncLib.h"
int MyMathFunc::Add(int a, int b)
{
return a + b;
}
int MyMathFunc::Subtract(int a, int b)
{
return a - b;
}
int MyMathFunc::Multiply(int a, int b)
{
return a * b;
}
double MyMathFunc::Divide(int a, int b)
{
return a / b;
}
Here is MainActivity.java file:
package com.example.test;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;//to use TextView
import android.widget.GridLayout.LayoutParams;//to use LayoutParams
public class MainActivity extends AppCompatActivity {
#Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
#Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int retVal = 0;
ExecuteTest et = new ExecuteTest();
retVal = et.TestAdd();
TextView tv = new TextView(this);
LayoutParams lp = new LayoutParams();
lp.setMargins(150, 50, 200, 0);
tv.setLayoutParams(lp);
tv.setText(String.valueOf(retVal));
setContentView(tv);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here is ExecuteTest.java file:
package com.example.test;
import android.util.Log;
public class ExecuteTest {
public int ReturnValue(){
return 50;
}
public native int TestAdd();
static
{
System.loadLibrary("MathFuncLib");
System.loadLibrary("Arithmetic");
Log.i ("ExecuteTest", "Shared Libs loaded");
}
}
Here is TestMath.cpp file:
#include <jni.h>
#include <string.h>
#include <android/log.h>
#include "../myNatives/MathFuncLib.h"
extern "C"
{
JNIEXPORT int JNICALL Java_com_example_test_ExecuteTest_TestAdd(JNIEnv *env, jobject obj)
{
__android_log_print(ANDROID_LOG_INFO, "Test", "Inside TestAdd()");
int retVal= Add(50,50);//Add(,) is a method inside MathFuncLib.so file
return retVal;
}
}
Here us my Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MathFuncLib-prebuilt
LOCAL_SRC_FILES := ../myLibs/armeabi/libMathFuncLib.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Arithmetic
LOCAL_SRC_FILES := TestMath.cpp
LOCAL_LDLIBS := -llog -lz
include $(BUILD_SHARED_LIBRARY)
Here is Application.mk file:
APP_STL := gnustl_shared
Thanks.
This is the correct form for
Application.mk
APP_ABI := x86 ## -- set to whatever platform you need
APP_PLATFORM := android-9
APP_STL := stlport_static ## -- USE IT
.
As for Android.mk you will need 2, because I see you want to build a solution using two projects --
a native (non-JNI) library
2nd native (JNI) library, that loads the first and makes it available to JAVA through JNI
Application.mk should be duplicated.
.
Android.mk (the native part)
include $(CLEAR_VARS)
#
# --------------- C / C++ Project settings ---------------
#
LOCAL_PATH := _path_to__myNatives
# Application/Library Name
LOCAL_MODULE := MathFunc
# Project Source files
LOCAL_SRC_FILES := MathFuncLibs.cpp
# Compiler Flags
LOCAL_CFLAGS := -mfpu=neon
### THIS BIT BELOW IS IMPORTANT -- used so that projects that include this build output will find the correct headers ###
# Location of headers
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.
#
# ------------------------- .. ----------------------------
#
include $(BUILD_STATIC_LIBRARY)
.
You would be using Eclipse, so you can then find the output in _path_to__myNatives/obj/local/$(TARGET_ARCH_ABI)/libMathFunc.a. $(TARGET_ARCH_ABI) evaluates to x86 in this example.
Need to build once for your platform (specified in Application.mk).
.
Android.mk (the native JNI part )
replace "Static" with "Shared" (no quotes ofc)
#
# -------------- Dependant Static Libraries Linkage ---------------
#
include $(CLEAR_VARS)
LOCAL_PATH := _path_to__myNatives
LOCAL_MODULE := MathFuncLib ## can be different from the previous module name definition in Android.mk or can be the same
LOCAL_SRC_FILES := $(LOCAL_PATH)/obj/local/$(TARGET_ARCH_ABI)/libMathFunc.a
include $(PREBUILT_STATIC_LIBRARY)
#
# ------------------------- .. ----------------------------
#
#
# --------------- C / C++ Project settings ----------------
#
include $(CLEAR_VARS)
LOCAL_PATH := _path_to___jni
# Application/Library Name
LOCAL_MODULE := Arithmetic
# Project Source files
LOCAL_SRC_FILES := TestMath.cpp
# Compiler Flags
LOCAL_CFLAGS := -mfpu=neon
LOCAL_LDLIBS := -llog -lz
# Static Libraries
LOCAL_STATIC_LIBRARIES := MathFuncLib # must be exactly the same as in THIS .mk file
# Shared Libraries
#LOCAL_SHARED_LIBRARIES := MathFuncLib # must be exactly the same as in THIS .mk file
#
# ------------------------- .. ----------------------------
#
include $(BUILD_SHARED_LIBRARY)
Just want to share my fixed.
1) in my MyMathFunc.h file, I shouldn't use "extern C" because C does not support class. If wanting to use "extern C" then I have to remove class declaration.
2) need to change Android.mk and Application.mk files.
Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MathFuncLib
LOCAL_SRC_FILES := ../myLibs/armeabi/libMathFuncLib.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES := MathFuncLib
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../myNatives/
LOCAL_MODULE := Arithmetic
LOCAL_SRC_FILES := TestMath.cpp
LOCAL_LDLIBS := -llog -lz
#Tell it to build an APK
include $(BUILD_SHARED_LIBRARY)
Application.mk file:
APP_STL := gnustl_shared
Related
It gives an error and couldn't load .so files. I searched it on the internet and read many things but didn't find an answer. I tried to use System.loadLibrary("jni_latinime") but it failed again. Please give me any advice. Thanks.
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.android.inputmethod.latin-1/base.apk"],nativeLibraryDirectories=[/data/app/com.android.inputmethod.latin-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjni_latinime.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at com.android.inputmethod.latin.utils.JniUtils.<clinit>(JniUtils.java:33)
at com.android.inputmethod.latin.utils.JniUtils.loadNativeLibrary(JniUtils.java:46)
at com.android.inputmethod.latin.LatinIME.<clinit>(LatinIME.java:599)
at java.lang.Class.newInstance(Native Method)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
1.Set NDK PATH
2.add this in build.gradle
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
3.Create a Jni folder inside SRC direactory
4.Create- Android.mk--inside jni folder-
5.add in Android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := "module name"//added inside system.load(); ** i used addjni**
LOCAL_SRC_FILES := Native.c //create a native.c class
LOCAL_LDLIBS := -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
6.Create a file Application.mk---inside jni folder----------------
and write this
APP_ABI := all
7.add inside MainActivity
public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("addjni");
}
TextView sum;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sum=(TextView)findViewById(R.id.sum);
int as=Native.sumoftwo(210,15);
Log.e("sum",as+"");
sum.setText(as+"");
}
}
8.create a new NativeNDK.c
//inside jni folder and add this
//jave_packageName_Native(Classname)_(methodname) replace(. with -)
include<string.h>
include<jni.h>
jint JNICALL Java_droider_Native_sumoftwo(JNIEnv* env , jclass obj,jint a,jint b)
{
jint total=(a+b);
return total;
}
9. go to studio terminal and inside type command
cd app\src\main>D:\android-ndk-r10d\android-ndk-r10d\ndk-build APP_PLATFORM=android-8 enter
10. Native.c inside main/src
public class Native {
public native static int sumoftwo(int a,int b);
static {
System.loadLibrary("addjni");
}
}
11.copy all .so from libs and paste into jinLibs if exist else create and paste
Go to LatinIME/native/jni and build it with ndk-build..
(if it contains errors just open Android.mk and comment this line :
# LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
# -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
# -Woverloaded-virtual -Wsign-promo -Wno-system-headers
This will build jni_latinime.so file...
You can add it to your build.gradle by giving this code:
sourceSets {
main {
jniLibs.srcDirs = ['LOCATION OF .so File']
}
}
I am getting problem in Using OpenCV Nonfree Module in Android. I read this tutorial
https://sites.google.com/site/wghsite/technical-notes/sift_surf_opencv_android
But after running ndk-build,it shows following errors..
guru#guru-Aspire-5738:~/Android/OpenCVWorkspace/sift_opencv_android/jni$ ~/Android/android-ndk-r9/ndk-build
Install : libopencv_java.so => libs/armeabi-v7a/libopencv_java.so
Install : libnonfree.so => libs/armeabi-v7a/libnonfree.so
Compile++ thumb : test_sift <= test_sift.cpp
/home/guru/Android/OpenCVWorkspace/sift_opencv_android/jni/test_sift.cpp:2:33: fatal error: opencv2/core/core.hpp: No such file or directory
compilation terminated.
make: ***[/home/guru/Android/OpenCVWorkspace/sift_opencv_android/obj/local/armeabi-v7a/objs/test_sift/test_sift.o] Error 1
Here is my code..
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 3)
{
cout <<" Usage: sift input_image output_image" << endl;
return -1;
}
//cv::initModule_nonfree();
//cout <<"initModule_nonfree() called" << endl;
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
if(! image.data )
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
vector<KeyPoint> keypoints;
Mat descriptors;
// Create a SIFT keypoint detector.
SiftFeatureDetector detector;
detector.detect(image, keypoints);
cout << "Detected " << (int) keypoints.size() << " keypoints" <<endl;
// Compute feature description.
detector.compute(image,keypoints, descriptors);
cout << "Computed feature."<<endl;
// Store description to "descriptors.des".
FileStorage fs;
fs.open("descriptors.des", FileStorage::WRITE);
cout << "Opened file to store the features."<<endl;
fs << "descriptors" << descriptors;
cout << "Finished writing file."<<endl;
fs.release();
cout << "Released file."<<endl;
// Show keypoints in the output image.
Mat outputImg;
Scalar keypointColor = Scalar(0, 0, 255);
drawKeypoints(image, keypoints, outputImg, keypointColor, DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cout << "Drew keypoints in output image file."<<endl;
namedWindow("Output image", CV_WINDOW_NORMAL );
imshow("Output image", outputImg);
waitKey(0);
cout << "Generate the output image."<<endl;
imwrite(argv[2], outputImg);
cout << "Done."<<endl;
return 0;
}
My Android.mk is ..
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sift_prebuilt
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_java_prebuilt
LOCAL_SRC_FILES := libopencv_java.so
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_C_INCLUDE:= /home/guru/Android/OpenCV-2.4.6-android-sdk/sdk/native/jni/include
LOCAL_MODULE := test_sift
LOCAL_LDLIBS += -llog -ldl
LOCAL_SHARED_LIBRARIES := sift_prebuilt opencv_java_prebuilt
LOCAL_SRC_FILES := test_sift.cpp
include $(BUILD_EXECUTABLE)
pls help..
I think you forgot to include "opencv2/core/core.hpp". Here is your include:
LOCAL_C_INCLUDE:= /home/guru/Android/OpenCV-2.4.6-android-sdk/sdk/native/jni/include
add "opencv2/core/core.hpp" to LOCAL_C_INCLUDE.
I'm trying simple addition program in android ndk. But I'm getting the following exception -
java.lang.exceptionininitializererror
Java File-
public class MainActivity extends Activity {
private native void MyMethod(int a,int b);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyMethod(4,5);
}
static {
System.loadLibrary("native"); // here i'm getting exception
}
}
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := native
LOCAL_SRC_FILES := native.c
include $(BUILD_STATIC_LIBRARY)
native.c
#include <jni.h>
#include <string.h>
#include <android/log.h>
#define DEBUG_TAG "NDKSetupActivity"
void Java_com_example_additionndk_MainActivity_MyMethod(JNIEnv * env, jobject this, jint a,jint b)
{
jint c=a+b;
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "addition: %d", c);
}
I ran into this error once when running the sample ndk (hello-jni). It's because the android sdk version is not compatible (default of the example is 1.5). Try to switch the compatible sdk and modifiy manifest .
Another case is you haven't build the .c to .so. Use ndk-build from cygwin64.
I found some similar questions, but their answers didn't help me. I went through this tutorial http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ and get some problems with it.
My Android.mk file :
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_PATH)
LOCAL_LDLIBS := -llog -ldl
LOCAL_MODULE := ndkfoo
LOCAL_SRC_FILES := ndkfoo.c
include $(BUILD_SHARED_LIBRARY)
And my c-class ndkfoo.c :
#include <jni.h>
#include <string.h>
#include <android/log.h>
#include <string.h>
#include <jni.h>
jstring Java_com_example_ocrrecognise_ndkfoo_MainActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) {
return (*env)->NewStringUTF(env, "Hello from native code!");
}
and MainActivity:
public class MainActivity extends Activity {
static {
System.loadLibrary("ndkfoo");
}
private native String invokeNativeFunction();
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
try{
String hello = invokeNativeFunction();
Log.i("string func", hello);
}catch (UnsatisfiedLinkError e)
{
e.printStackTrace();
}
//new AlertDialog.Builder(MainActivity.this).setMessage(hello).show();
}
});
}
But I've got
No implementation found for native Lcom/example/ocrrecognise/MainActivity;.invokeNativeFunction ()Ljava/lang/String;
java.lang.UnsatisfiedLinkError: invokeNativeFunction
at com.example.ocrrecognise.MainActivity.invokeNativeFunction(Native Method)
at com.example.ocrrecognise.MainActivity.access$0(MainActivity.java:14)
at com.example.ocrrecognise.MainActivity$1.onClick(MainActivity.java:24)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
My in the ndkfoo.c I put right package name. Help with it please.
In what package your Activity is in?
Please mind that is should be under com.example.ocrrecognise.ndkfoo.
How did you compile your c code?
Did you put the compile .so file under /libs/armeabi in your project?
From the error
No implementation found for native Lcom/example/ocrrecognise/MainActivity;.invokeNativeFunction
it appears that your main activity is in the package com.example.ocrrecognise. If you place it in package com_example_ocrrecognise_ndkfoo, it should work, since that is the prefix that you are using in declaring the function in your native code.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I need to build the FreeImage.a library for my Android project. I've downloaded the source code from the project page.
How do I build this project from the original sources when targeting Android?
To build FreeImage 3.15.3 for Android from the original sources you will need 3 things:
1) create file jni/Application.mk in FreeImage folder:
APP_OPTIM := release
APP_PLATFORM := android-8
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI := armeabi-v7a x86
APP_MODULES := FreeImage
2) create file jni/Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
GLOBAL_C_INCLUDES := \
$(LOCAL_PATH)/../Source \
$(LOCAL_PATH)/../Source \
$(LOCAL_PATH)/../Source/DeprecationManager \
$(LOCAL_PATH)/../Source/FreeImage \
$(LOCAL_PATH)/../Source/FreeImageLib \
$(LOCAL_PATH)/../Source/FreeImageToolkit \
$(LOCAL_PATH)/../Source/LibJPEG \
$(LOCAL_PATH)/../Source/LibMNG \
$(LOCAL_PATH)/../Source/LibOpenJPEG \
$(LOCAL_PATH)/../Source/LibPNG \
$(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_PATH)/../Source/LibTIFF \
$(LOCAL_PATH)/../Source/Metadata \
$(LOCAL_PATH)/../Source/OpenEXR \
$(LOCAL_PATH)/../Source/OpenEXR/Copyrights \
$(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/ZLib \
LOCAL_SRC_FILES = ../Source/FreeImage/BitmapAccess.cpp ../Source/FreeImage/ColorLookup.cpp ../Source/FreeImage/FreeImage.cpp ../Source/FreeImage/FreeImageC.c ../Source/FreeImage/FreeImageIO.cpp ../Source/FreeImage/GetType.cpp ../Source/FreeImage/MemoryIO.cpp ../Source/FreeImage/PixelAccess.cpp ../Source/FreeImage/J2KHelper.cpp ../Source/FreeImage/MNGHelper.cpp ../Source/FreeImage/Plugin.cpp ../Source/FreeImage/PluginBMP.cpp ../Source/FreeImage/PluginCUT.cpp ../Source/FreeImage/PluginDDS.cpp ../Source/FreeImage/PluginEXR.cpp ../Source/FreeImage/PluginG3.cpp ../Source/FreeImage/PluginGIF.cpp ../Source/FreeImage/PluginHDR.cpp ../Source/FreeImage/PluginICO.cpp ../Source/FreeImage/PluginIFF.cpp ../Source/FreeImage/PluginJ2K.cpp ../Source/FreeImage/PluginJNG.cpp ../Source/FreeImage/PluginJP2.cpp ../Source/FreeImage/PluginJPEG.cpp ../Source/FreeImage/PluginKOALA.cpp ../Source/FreeImage/PluginMNG.cpp ../Source/FreeImage/PluginPCD.cpp ../Source/FreeImage/PluginPCX.cpp ../Source/FreeImage/PluginPFM.cpp ../Source/FreeImage/PluginPICT.cpp ../Source/FreeImage/PluginPNG.cpp ../Source/FreeImage/PluginPNM.cpp ../Source/FreeImage/PluginPSD.cpp ../Source/FreeImage/PluginRAS.cpp ../Source/FreeImage/PluginRAW.cpp ../Source/FreeImage/PluginSGI.cpp ../Source/FreeImage/PluginTARGA.cpp ../Source/FreeImage/PluginTIFF.cpp ../Source/FreeImage/PluginWBMP.cpp ../Source/FreeImage/PluginXBM.cpp ../Source/FreeImage/PluginXPM.cpp ../Source/FreeImage/PSDParser.cpp ../Source/FreeImage/TIFFLogLuv.cpp ../Source/FreeImage/Conversion.cpp ../Source/FreeImage/Conversion16_555.cpp ../Source/FreeImage/Conversion16_565.cpp ../Source/FreeImage/Conversion24.cpp ../Source/FreeImage/Conversion32.cpp ../Source/FreeImage/Conversion4.cpp ../Source/FreeImage/Conversion8.cpp ../Source/FreeImage/ConversionFloat.cpp ../Source/FreeImage/ConversionRGB16.cpp ../Source/FreeImage/ConversionRGBF.cpp ../Source/FreeImage/ConversionType.cpp ../Source/FreeImage/ConversionUINT16.cpp ../Source/FreeImage/Halftoning.cpp ../Source/FreeImage/tmoColorConvert.cpp ../Source/FreeImage/tmoDrago03.cpp ../Source/FreeImage/tmoFattal02.cpp ../Source/FreeImage/tmoReinhard05.cpp ../Source/FreeImage/ToneMapping.cpp ../Source/FreeImage/NNQuantizer.cpp ../Source/FreeImage/WuQuantizer.cpp ../Source/DeprecationManager/Deprecated.cpp ../Source/DeprecationManager/DeprecationMgr.cpp ../Source/FreeImage/CacheFile.cpp ../Source/FreeImage/MultiPage.cpp ../Source/FreeImage/ZLibInterface.cpp ../Source/Metadata/Exif.cpp ../Source/Metadata/FIRational.cpp ../Source/Metadata/FreeImageTag.cpp ../Source/Metadata/IPTC.cpp ../Source/Metadata/TagConversion.cpp ../Source/Metadata/TagLib.cpp ../Source/Metadata/XTIFF.cpp ../Source/FreeImageToolkit/Background.cpp ../Source/FreeImageToolkit/BSplineRotate.cpp ../Source/FreeImageToolkit/Channels.cpp ../Source/FreeImageToolkit/ClassicRotate.cpp ../Source/FreeImageToolkit/Colors.cpp ../Source/FreeImageToolkit/CopyPaste.cpp ../Source/FreeImageToolkit/Display.cpp ../Source/FreeImageToolkit/Flip.cpp ../Source/FreeImageToolkit/JPEGTransform.cpp ../Source/FreeImageToolkit/MultigridPoissonSolver.cpp ../Source/FreeImageToolkit/Rescale.cpp ../Source/FreeImageToolkit/Resize.cpp ../Source/LibJPEG/./jaricom.c ../Source/LibJPEG/jcapimin.c ../Source/LibJPEG/jcapistd.c ../Source/LibJPEG/./jcarith.c ../Source/LibJPEG/jccoefct.c ../Source/LibJPEG/jccolor.c ../Source/LibJPEG/jcdctmgr.c ../Source/LibJPEG/jchuff.c ../Source/LibJPEG/jcinit.c ../Source/LibJPEG/jcmainct.c ../Source/LibJPEG/jcmarker.c ../Source/LibJPEG/jcmaster.c ../Source/LibJPEG/jcomapi.c ../Source/LibJPEG/jcparam.c ../Source/LibJPEG/jcprepct.c ../Source/LibJPEG/jcsample.c ../Source/LibJPEG/jctrans.c ../Source/LibJPEG/jdapimin.c ../Source/LibJPEG/jdapistd.c ../Source/LibJPEG/./jdarith.c ../Source/LibJPEG/jdatadst.c ../Source/LibJPEG/jdatasrc.c ../Source/LibJPEG/jdcoefct.c ../Source/LibJPEG/jdcolor.c ../Source/LibJPEG/jddctmgr.c ../Source/LibJPEG/jdhuff.c ../Source/LibJPEG/jdinput.c ../Source/LibJPEG/jdmainct.c ../Source/LibJPEG/jdmarker.c ../Source/LibJPEG/jdmaster.c ../Source/LibJPEG/jdmerge.c ../Source/LibJPEG/jdpostct.c ../Source/LibJPEG/jdsample.c ../Source/LibJPEG/jdtrans.c ../Source/LibJPEG/jerror.c ../Source/LibJPEG/jfdctflt.c ../Source/LibJPEG/jfdctfst.c ../Source/LibJPEG/jfdctint.c ../Source/LibJPEG/jidctflt.c ../Source/LibJPEG/jidctfst.c ../Source/LibJPEG/jidctint.c ../Source/LibJPEG/jmemmgr.c ../Source/LibJPEG/jmemnobs.c ../Source/LibJPEG/jquant1.c ../Source/LibJPEG/jquant2.c ../Source/LibJPEG/jutils.c ../Source/LibJPEG/transupp.c ../Source/LibPNG/./png.c ../Source/LibPNG/./pngerror.c ../Source/LibPNG/./pngget.c ../Source/LibPNG/./pngmem.c ../Source/LibPNG/./pngpread.c ../Source/LibPNG/./pngread.c ../Source/LibPNG/./pngrio.c ../Source/LibPNG/./pngrtran.c ../Source/LibPNG/./pngrutil.c ../Source/LibPNG/./pngset.c ../Source/LibPNG/./pngtrans.c ../Source/LibPNG/./pngwio.c ../Source/LibPNG/./pngwrite.c ../Source/LibPNG/./pngwtran.c ../Source/LibPNG/./pngwutil.c ../Source/LibTIFF4/./tif_aux.c ../Source/LibTIFF4/./tif_close.c ../Source/LibTIFF4/./tif_codec.c ../Source/LibTIFF4/./tif_color.c ../Source/LibTIFF4/./tif_compress.c ../Source/LibTIFF4/./tif_dir.c ../Source/LibTIFF4/./tif_dirinfo.c ../Source/LibTIFF4/./tif_dirread.c ../Source/LibTIFF4/./tif_dirwrite.c ../Source/LibTIFF4/./tif_dumpmode.c ../Source/LibTIFF4/./tif_error.c ../Source/LibTIFF4/./tif_extension.c ../Source/LibTIFF4/./tif_fax3.c ../Source/LibTIFF4/./tif_fax3sm.c ../Source/LibTIFF4/./tif_flush.c ../Source/LibTIFF4/./tif_getimage.c ../Source/LibTIFF4/./tif_jpeg.c ../Source/LibTIFF4/./tif_luv.c ../Source/LibTIFF4/./tif_lzma.c ../Source/LibTIFF4/./tif_lzw.c ../Source/LibTIFF4/./tif_next.c ../Source/LibTIFF4/./tif_ojpeg.c ../Source/LibTIFF4/./tif_open.c ../Source/LibTIFF4/./tif_packbits.c ../Source/LibTIFF4/./tif_pixarlog.c ../Source/LibTIFF4/./tif_predict.c ../Source/LibTIFF4/./tif_print.c ../Source/LibTIFF4/./tif_read.c ../Source/LibTIFF4/./tif_strip.c ../Source/LibTIFF4/./tif_swab.c ../Source/LibTIFF4/./tif_thunder.c ../Source/LibTIFF4/./tif_tile.c ../Source/LibTIFF4/./tif_version.c ../Source/LibTIFF4/./tif_warning.c ../Source/LibTIFF4/./tif_write.c ../Source/LibTIFF4/./tif_zip.c ../Source/ZLib/./adler32.c ../Source/ZLib/./compress.c ../Source/ZLib/./crc32.c ../Source/ZLib/./deflate.c ../Source/ZLib/./gzclose.c ../Source/ZLib/./gzlib.c ../Source/ZLib/./gzread.c ../Source/ZLib/./gzwrite.c ../Source/ZLib/./infback.c ../Source/ZLib/./inffast.c ../Source/ZLib/./inflate.c ../Source/ZLib/./inftrees.c ../Source/ZLib/./trees.c ../Source/ZLib/./uncompr.c ../Source/ZLib/./zutil.c ../Source/LibOpenJPEG/bio.c ../Source/LibOpenJPEG/./cidx_manager.c ../Source/LibOpenJPEG/cio.c ../Source/LibOpenJPEG/dwt.c ../Source/LibOpenJPEG/event.c ../Source/LibOpenJPEG/image.c ../Source/LibOpenJPEG/j2k.c ../Source/LibOpenJPEG/j2k_lib.c ../Source/LibOpenJPEG/jp2.c ../Source/LibOpenJPEG/jpt.c ../Source/LibOpenJPEG/mct.c ../Source/LibOpenJPEG/mqc.c ../Source/LibOpenJPEG/openjpeg.c ../Source/LibOpenJPEG/./phix_manager.c ../Source/LibOpenJPEG/pi.c ../Source/LibOpenJPEG/./ppix_manager.c ../Source/LibOpenJPEG/raw.c ../Source/LibOpenJPEG/t1.c ../Source/LibOpenJPEG/t2.c ../Source/LibOpenJPEG/tcd.c ../Source/LibOpenJPEG/tgt.c ../Source/LibOpenJPEG/./thix_manager.c ../Source/LibOpenJPEG/./tpix_manager.c ../Source/OpenEXR/./IlmImf/ImfAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfB44Compressor.cpp ../Source/OpenEXR/./IlmImf/ImfBoxAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfChannelList.cpp ../Source/OpenEXR/./IlmImf/ImfChannelListAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfChromaticities.cpp ../Source/OpenEXR/./IlmImf/ImfChromaticitiesAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfCompressionAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfCompressor.cpp ../Source/OpenEXR/./IlmImf/ImfConvert.cpp ../Source/OpenEXR/./IlmImf/ImfCRgbaFile.cpp ../Source/OpenEXR/./IlmImf/ImfDoubleAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfEnvmap.cpp ../Source/OpenEXR/./IlmImf/ImfEnvmapAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfFloatAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfFrameBuffer.cpp ../Source/OpenEXR/./IlmImf/ImfFramesPerSecond.cpp ../Source/OpenEXR/./IlmImf/ImfHeader.cpp ../Source/OpenEXR/./IlmImf/ImfHuf.cpp ../Source/OpenEXR/./IlmImf/ImfInputFile.cpp ../Source/OpenEXR/./IlmImf/ImfIntAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfIO.cpp ../Source/OpenEXR/./IlmImf/ImfKeyCode.cpp ../Source/OpenEXR/./IlmImf/ImfKeyCodeAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfLineOrderAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfLut.cpp ../Source/OpenEXR/./IlmImf/ImfMatrixAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfMisc.cpp ../Source/OpenEXR/./IlmImf/ImfOpaqueAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfOutputFile.cpp ../Source/OpenEXR/./IlmImf/ImfPizCompressor.cpp ../Source/OpenEXR/./IlmImf/ImfPreviewImage.cpp ../Source/OpenEXR/./IlmImf/ImfPreviewImageAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfPxr24Compressor.cpp ../Source/OpenEXR/./IlmImf/ImfRational.cpp ../Source/OpenEXR/./IlmImf/ImfRationalAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfRgbaFile.cpp ../Source/OpenEXR/./IlmImf/ImfRgbaYca.cpp ../Source/OpenEXR/./IlmImf/ImfRleCompressor.cpp ../Source/OpenEXR/./IlmImf/ImfScanLineInputFile.cpp ../Source/OpenEXR/./IlmImf/ImfStandardAttributes.cpp ../Source/OpenEXR/./IlmImf/ImfStdIO.cpp ../Source/OpenEXR/./IlmImf/ImfStringAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfStringVectorAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfTestFile.cpp ../Source/OpenEXR/./IlmImf/ImfThreading.cpp ../Source/OpenEXR/./IlmImf/ImfTileDescriptionAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfTiledInputFile.cpp ../Source/OpenEXR/./IlmImf/ImfTiledMisc.cpp ../Source/OpenEXR/./IlmImf/ImfTiledOutputFile.cpp ../Source/OpenEXR/./IlmImf/ImfTiledRgbaFile.cpp ../Source/OpenEXR/./IlmImf/ImfTileOffsets.cpp ../Source/OpenEXR/./IlmImf/ImfTimeCode.cpp ../Source/OpenEXR/./IlmImf/ImfTimeCodeAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfVecAttribute.cpp ../Source/OpenEXR/./IlmImf/ImfVersion.cpp ../Source/OpenEXR/./IlmImf/ImfWav.cpp ../Source/OpenEXR/./IlmImf/ImfZipCompressor.cpp ../Source/OpenEXR/./Imath/ImathBox.cpp ../Source/OpenEXR/./Imath/ImathColorAlgo.cpp ../Source/OpenEXR/./Imath/ImathFun.cpp ../Source/OpenEXR/./Imath/ImathMatrixAlgo.cpp ../Source/OpenEXR/./Imath/ImathRandom.cpp ../Source/OpenEXR/./Imath/ImathShear.cpp ../Source/OpenEXR/./Imath/ImathVec.cpp ../Source/OpenEXR/./Iex/IexBaseExc.cpp ../Source/OpenEXR/./Iex/IexThrowErrnoExc.cpp ../Source/OpenEXR/./Half/half.cpp ../Source/OpenEXR/./IlmThread/IlmThread.cpp ../Source/OpenEXR/./IlmThread/IlmThreadMutex.cpp ../Source/OpenEXR/./IlmThread/IlmThreadPool.cpp ../Source/OpenEXR/./IlmThread/IlmThreadSemaphore.cpp ../Source/LibRawLite/./internal/dcraw_common.cpp ../Source/LibRawLite/./internal/dcraw_fileio.cpp ../Source/LibRawLite/./internal/demosaic_packs.cpp ../Source/LibRawLite/./src/libraw_c_api.cpp ../Source/LibRawLite/./src/libraw_cxx.cpp ../Source/LibRawLite/./src/libraw_datastream.cpp
LOCAL_MODULE := FreeImage
GLOBAL_CFLAGS := -O3 -DHAVE_CONFIG_H=1 -DFREEIMAGE_LIB -isystem $(SYSROOT)/usr/include/
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS := $(GLOBAL_CFLAGS)
else
LOCAL_CFLAGS := -mfpu=vfp -mfloat-abi=softfp -fno-short-enums $(GLOBAL_CFLAGS)
endif
LOCAL_C_INCLUDES := $(GLOBAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
3) Provide some functions missing in Android's libc:
/// C-runtime patch
extern "C"
{
// used deep inside FreeImage
void* lfind( const void * key, const void * base, size_t num, size_t width, int (*fncomparison)(const void *, const void * ) )
{
char* Ptr = (char*)base;
for ( size_t i = 0; i != num; i++, Ptr+=width )
{
if ( fncomparison( key, Ptr ) == 0 ) return Ptr;
}
return NULL;
}
// used in libcompress
int fseeko64(FILE *stream, off64_t offset, int whence)
{
return fseek( stream, int( offset & 0xFFFFFFFF ), whence );
}
// used in libcompress
off64_t ftello64(FILE *stream)
{
return ftell( stream );
}
} // extern C
Now you can run ndk-build to compile your FreeImage.
P.S. Precompiled Android version is available from http://www.linderdaum.com within Linderdaum Engine SDK.