How To Create Native C++ Library On Android?
Solution 1:
For your example, use g++ instead of gcc, its a C++ program.
Look at the hello-jni sample in the NDK. You need to build your shared library using the NDK and import it into a Java Android project. In the Java code, you need to declare the native functions with 'native' and add the library using static; see snippet below.
public native String stringFromJNI();
static {
System.loadLibrary("hello-jni");
}
Solution 2:
You'll probably need the Android NDK to compile and link native libraries on Android. Cygwin and windows should work (cygwin provides the required *nix tools).
To me it looks like you compiled the c++ source for a WINTEL environment, which is totally different from android phones. So if you load that library to the phone, it will certainly crash/not work at all.
Here is an article that might help. It covers the android-ndk/cygwin part and should provide some pointers to more information.
EDIT
sigh - handed part of the error message to google and was surprised that there are no results with the user32 lib ... then I realized, that the part -luser32
effectively removed all user32
related links from the result list ;)
This is the most promising link: http://www.cygwin.com/ml/cygwin/2003-01/msg00292.html
Basiscally - run cygwin setup and add the package that contains the user32 lib. Then it should work.
Solution 3:
Look at the samples that come with the NDK. You need to use JNI bindings to allow it to communciate with Java. Under those bindings you can do whatever you like but anything that needs to be accessible from Java needs to go through the JNI bindings. Anything that DOESN'T need to be accessible can be written just as you normally would.
And yes its perfectly doable under windows.
Post a Comment for "How To Create Native C++ Library On Android?"