Jump to content
  • Advertisement
Sign in to follow this  
3DModelerMan

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

This topic is 2328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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). Edited by freakchild

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!