Android NDK动态库的调用
2010-09-16 23:50:00 来源:WEB开发网NDK动态库的调用分两种情况。第一种是:so库和调用程序在同一个目录和源程序 通过同一个mk文件来编译;另外一种情况是so是外部已经编译好了的,调用程序加载调用。下面我们就来分析下面2种so的调用情况:
第一部分: 内部so调用
A. 先看下工程的目录:
test01.java :Java文件
test01.c 主so,生成libtest.so,在libtest.so中调用libtutorial.so中的方法
tutorial01.c tutorial02.c tutorial02.h :生成libtutorial.so
B. 然后看下具体的mk文件的写法以及java中的文件内容
test01.java/*
* 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.
*/
package com.example.test;
import android.R.integer;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class test01 extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/* Create a TextView and set its content.
* the text is retrieved by calling a native
更多精彩
赞助商链接