Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 3DModelerMan   Members   -  Reputation: 997

Like
0Likes
Like

Posted 29 May 2012 - 07:01 PM

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?

Sponsor:

#2 freakchild   Members   -  Reputation: 557

Like
1Likes
Like

Posted 30 May 2012 - 09:49 AM

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 "$(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, 30 May 2012 - 09:55 AM.


#3 clb   Members   -  Reputation: 1781

Like
2Likes
Like

Posted 30 May 2012 - 10:04 AM

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).
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#4 3DModelerMan   Members   -  Reputation: 997

Like
1Likes
Like

Posted 31 May 2012 - 12:25 PM

Thanks. I think it's working now.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS