NDK two-libs例子编译时遇到的问题
1. 把second.c 文件扩展名改成second.cpp
2. 改进代码
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "first.h"
#include <jni.h>
#include<stdlib.h>
jint
Java_com_example_twolibs_TwoLibs_add( JNIEnv* env,
jobject obj,
jint x,
jint y )
{
return first(x, y);
}
编译时出现
Administrator@PC2010111818iqp /cygdrive/d/android-ndk-r4/samples/two-libs
$ $NDK_ROOT/ndk-build
Compile++ thumb: twolib-second <= /cygdrive/d/android-ndk-r4/samples/two-libs/jn
i/second.cpp
SharedLibrary : libtwolib-second.so
/cygdrive/d/android-ndk-r4/samples/two-libs/bin/ndk/local/armeabi/objs/twolib-se
cond/second.o: In function `Java_com_example_twolibs_TwoLibs_add(_JNIEnv*, _jobj
ect*, int, int)':
/cygdrive/d/android-ndk-r4/samples/two-libs/jni/second.cpp:26: undefined referen
ce to `first(int, int)'
collect2: ld returned 1 exit status
make: *** [/cygdrive/d/android-ndk-r4/samples/two-libs/bin/ndk/local/armeabi/lib
twolib-second.so] Error 1
Administrator@PC2010111818iqp /cygdrive/d/android-ndk-r4/samples/two-libs
$
求教. 这是什么问题. 有没有办法解决 ?