English 中文(简体)
我如何为安伯茨准备文件,以建设这些档案?
原标题:How do I prepare my .cpp files for the Android ndk to build them?

目前,我们有一些图像处理软件在C++中书写,目前正由我们的IOS应用程序使用。 我正试图将这一图像处理法纳入我利用安的NDK创建的roid项目。

我有我的roid子项目,并 all了所有装置,准备去。 我也准备到会。

I was following through on this tutorial (which is awesome), and I got stumped at the part that he defined the code for native.c because it had a function name like this,

void Java_com_mamlambo_sample_ndk1_AndroidNDK1SampleActivity_helloLog(JNIEnv * env, jobject this, jstring logThis) 

我几乎想像我这样想到,我必须履行我现有的所有工作,改变法典,以便国家科索沃警察部队认识到这一点。

因此,我的问题是:

  1. Do I have to alter my existing c++ code in order for it to work with the ndk builder? And if so, what are the things I need to change in my code for this work?
  2. Is there a way to have the Android.mk file build an entire directory? I have a lot of files and I did not want to have to list out every single one of them in order to get them built.
最佳回答

(1) 您应能在不作改动的情况下获得build<>em>,但您需要写一下荷兰广播公司的一些总结职能,以便从 Java叫它。 希望你有少数高级班级,你只需要总结。 E.g. 下面是我为游戏一米(低度)撰写的文章:

// android.cpp
#include "game.h"
#include <jni.h>

namespace {
    Game* toGame(jlong gamePtr) {
        return reinterpret_cast<Game*>(gamePtr);
    }
}

extern "C" {

    jlong Java_com_rarepebble_game3_Game_create(JNIEnv* env, jobject jobj) {
        Game* g = new Game();
        return reinterpret_cast<jlong>(g);
    }

    void Java_com_rarepebble_game3_Game_destroy(JNIEnv* env, jobject jobj, jlong gamePtr) {
        delete toGame(gamePtr);
    }

    void Java_com_rarepebble_game3_Game_update(JNIEnv* env, jobject jobj, jlong gamePtr, jboolean isTouching, jfloat touchX, jfloat touchY) {
        toGame(gamePtr)->update(isTouching, touchX, touchY);
    }

    void Java_com_rarepebble_game3_Game_render(JNIEnv* env, jobject jobj, jlong gamePtr) {
        toGame(gamePtr)->render();
    }

    // ... and a few others. Only one class, though.
}

在贾瓦那一侧,请允许我在我的<代码>com.rarepebble.ega3.Game类别中宣布这些职能,并在使用寿命周期的适当时间将其称作这些职能。 (说明 Java一揽子计划、类别和职能名称如何与C++的功能名称相符):

//Game.java
package com.rarepebble.game3;

// (imports)

public class Game {
    static {
        System.loadLibrary("game3lib");
    }
    // These are the functions you defined in C++
    private native long create();
    private native void destroy(long gamePtr);    
    private native void update(long gamePtr, boolean isTouched, float x, float y);
    private native void render(long gamePtr);

    private long gamePtr = 0;

    Game() {
        gamePtr = create();
    }

    @Override
    protected void finalize() throws Throwable {
        if (gamePtr != 0) {
            destroy(gamePtr);
        }
        super.finalize();
    }

    // etc...
}

2) 你可以使用

LOCAL_SRC_FILES := (wildcard *.cpp)$ (wildcard subdirectory/*.cpp) #etc.

<><>Edit>: 按照要求,我的C++ 猎物组长,“ga.h”:

// game.h
#ifndef GAME_INCLUDED
#define GAME_INCLUDED

// Various game and standard library includes.
// *NO* JNI or Android includes.

namespace game {

    class Game {
    public:
        Game();
        ~Game();

        void update(bool isTouching, float touchX, float touchY);
        void render();

        // other funcs...

    private:
        // etc...
    };

}

#endif //def GAME_INCLUDED  

同样,“加固剂”也含有任何日本民族权力机构的 st。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...