How to generate wrapper files using swig :
1)Install Swig using the following link
http://www.swig.org/download.html
2)Copy in your folder and from cmd prompt go the location and type the following command
swig -c++ -java path
Where path indicates location of .i file[which is mandatory to generate wrapper classes]
3)Corresponding wrapper classes will be generated and then build using eclipse before building in eclipse follow the below steps
4)Set Ndk path in window--->preferences --->Android--->Ndk
5)Go to project properties c/c++ build --->Tool chain Editor and there set CurrentBuilder as Android Builder.
6)Navigate to C/C++ build there in Builder Settings following should be mentioned
Build Directory should be : ${workspace_loc:/Project Name}/
Build Command : ndk - build
7)Build will be successful refer make file for any directory mismatch
One of the reason why I faced UnsatisfiedLinkError while trying to call native function is:
I have build JNIWrapper using the followinh Swig command
C:\swig\swigwin-2.0.11\swigwin-2.0.11>swig -c++ -java -package com.sampel D:\Pro
j-workspace\All_Projects\nativecodeproject\jni\API.i
All the wrappers got generated with the above package name.
I had a file with .cxx extension[which serves as a linkage between the Java and the Cpp code]
which plays a primary role while invoking native functions.
This .cxx file is also generated by swig when I run the above command.
As per the make file Android makefile I shoul copy it and paste it in the target folder.
I missed out the above step and this lead to Error.
Note android make file instructions should be folloed carefully and .cxx file should be placed in their appropriate positions
1)Install Swig using the following link
http://www.swig.org/download.html
2)Copy in your folder and from cmd prompt go the location and type the following command
swig -c++ -java path
Where path indicates location of .i file[which is mandatory to generate wrapper classes]
3)Corresponding wrapper classes will be generated and then build using eclipse before building in eclipse follow the below steps
4)Set Ndk path in window--->preferences --->Android--->Ndk
5)Go to project properties c/c++ build --->Tool chain Editor and there set CurrentBuilder as Android Builder.
6)Navigate to C/C++ build there in Builder Settings following should be mentioned
Build Directory should be : ${workspace_loc:/Project Name}/
Build Command : ndk - build
7)Build will be successful refer make file for any directory mismatch
One of the reason why I faced UnsatisfiedLinkError while trying to call native function is:
I have build JNIWrapper using the followinh Swig command
C:\swig\swigwin-2.0.11\swigwin-2.0.11>swig -c++ -java -package com.sampel D:\Pro
j-workspace\All_Projects\nativecodeproject\jni\API.i
All the wrappers got generated with the above package name.
I had a file with .cxx extension[which serves as a linkage between the Java and the Cpp code]
which plays a primary role while invoking native functions.
This .cxx file is also generated by swig when I run the above command.
As per the make file Android makefile I shoul copy it and paste it in the target folder.
I missed out the above step and this lead to Error.
Note android make file instructions should be folloed carefully and .cxx file should be placed in their appropriate positions
No comments:
Post a Comment