Compiling with NDK without stuffing C++ code in JNI folder?

Started by
2 comments, last by 3DModelerMan 11 years, 10 months ago
Is there any way to do this? I have a C++ engine that runs on Windows and it uses the typical structure of having an "Engine/source", "Engine/include", "Engine/lib", etc. I want to be able to set up a set of Android specific classes used when compiling with the NDK, but I don't want to stick all my C++ code into a JNI folder. Is there a way to change the NDK's include and source directories when building?
Advertisement

Is there any way to do this?


Yes, you can.

From the root of your NDK directory look at the /docs/IMPORT-MODULE.html (<ndkroot>/docs/IMPORT-MODULE.html) documentation which describes this process in detail. The gist of it is to make sure your NDK_MODULE_PATH environment variable is set up so that it considers the new directories. Setup an Android.mk for these new modules and then insert a "[color=#000000]$(call import-module,modulename)" at the end of your original Android.mk (the one for the project/jni directory).

Alternatively, you can also build your external source into libraries and use the method described in <ndkroot>/docs/PREBUILTS.html.

I do believe there are other ways too. All is covered in the NDK docs, but these are the only two I've tried and can speak to. Apologies because I was going to post a basic example. Only one of the other programmers has made it so that it is no longer so 'basic'.

Do read those documents over several times both before and as you set it up. It it is in theory quite straightforward, but getting it to work at all and then to work well is a little more difficult. I had to keep going back to the docs and every time that I did previously overlooked or seemingly unrelated information became more relevant.

Bear in mind all the documentation is linked from '<ndkroot>\documentation.html'. Because this can be a little cumbersome, I would suggest reading over many of the documentation pages linked from here, in addition to the two I've pointed out above. There are many clarifying nuggets buried in a lot of these other pages, including the one that covers setting up the Android.mk (<ndkroot>/docs/ANDROID-MK.html).
If you are on windows, you can also use the vs-android plugin, which enables you to compile your solution/projects for Android, independent of which directories your code files lie in. The plugin appears in the Solution Platform dropdown menu, see http://dl.dropbox.com/u/40949268/emcc/vs-tool.png (the other items in that image are from my vs-tool plugin, which is an adaptation of the vs-android plugin for other architectures).
Thanks. I think it's working now.

This topic is closed to new replies.

Advertisement