RT
By learning java jni call C code.
With Eclipse creates a Android Application Project, named zcJniTest2.
Under the project directory create a folder jni, write Android.mk files and zcCallback.c, zcTest.h, zcTest.c file.
Content zcCallback.c as follows:
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Define LOGI (...) ((void) __android_log_print (ANDROID_LOG_INFO, "native-activity", __ VA_ARGS__))
# Define LOGW (...) ((void) __android_log_print (ANDROID_LOG_WARN, "native-activity", __ VA_ARGS__))
/ / ***
# Include "zcTest.h"
JNIEXPORT int JNICALL Java_com_example_zcjnitest2_MainActivity_TTT (
JNIEnv * env, jobject obj, int _i)
{
/ / ZcTest (); / / Now here is commented out.
}
Content zcTest.h as follows:
# Ifndef __ ZC_TEST_H_20131016__
# Define __ ZC_TEST_H_20131016__
void zcTest ();
# Endif / / __ ZC_TEST_H_20131016__
Content zcTest.c as follows:
void zcTest ()
{}
In this case, use the command ndk-build to compile time is OK.
Then zcCallback.c the JNICALL Java_com_example_zcjnitest2_MainActivity_TTT to read as follows:
JNIEXPORT int JNICALL Java_com_example_zcjnitest2_MainActivity_TTT (
JNIEnv * env, jobject obj, int _i)
{
zcTest (); / / above code here is commented out.
}
At this point, then ndk-build command to compile error "error: undefined reference to 'zcTest'".
not already "# include" zcTest.h "" it? How will not find zcTest? ?
How should I get? ? How to modify? ? Seeking advice, seeking advice, help out, thank you.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Reference \ android-ndk-r8e \ samples \ two-libs in this example, and you exactly the same
Mk file should be written right
Reply:
thanks
No comments:
Post a Comment