Best way to set up a native static lib?

Yes, I’m a complete noob when it comes to Android programming.

I’m trying to setup a cocos2dx app, and would like to understand how to setup the project. It’s Java+Native, so there’s a single call to LoadLibrary to load the app’s native .so. I need to be able to setup some cocos2dx static libraries projects that will generate a number of .a files to be linked into the .so. What’s the best way? There doesn’t seem to be an Android project template for static libs. I can select a native app template, then change the configuration to static lib, but that leaves me with a lot of auto-generated stuff I’m pretty sure I don’t need (or do I?).

I notice also that the nv_* static lib projects have a simple simple structure that I probably need to emulate, but what’s the best way to get there? Do I start with a native app template then remove all the bits I don’t need?

Also, the nv_* static lib projects contain an, as to the other samples, which also contain an But these files does not seem to get auto-generated when I create a new java+native app. Must I create and maintain these myself, in parallel with the Visual Studio project? And if I must do this, are there plans to manage these via the Visual Studio gui in the future? I mean, if I add files to the project, I would expect them to be reflected in the, for example, and for project compile settings to be available in the GUI, and reflected in

Is there a best-practices doc? I looked in the TADP ‘docs’ directory, but it did not contain anything to provide direction.

Hi, Bill

Sorry we don’t have enough documentation for this. and are used by NDK-build, that’s not auto generated in the Visual Studio tool. We provided those files to make the project compatible with ndk-build. Changes in VS will not be reflected in .mk files. We don’t have plan to support maintain .mk files so far.

To make a static lib project, you can start from any template and remove the bits you don’t need. Just to change the “Configuration Type” in project setting to "Static Lib (.a) "

Thank you. I’ve done this, and it works great.

I’m having trouble understanding how to develop without the MK files. I’ve created a new lib project to include Box2D library to my main project.

Now, what should I do? What are the steps to accomplish this?

Thanks for advance!

Hello Xertz,

Could you please clarify what are you trying to achieve?

Hi Dmitry!

I was trying to add a Box2D static library onto my main project. I finally got it working!

Because I didn’t know how to do it without the MK files, I’d struggle a lot searching the solution. Thankfully with the sample projects provided with the DevPackt, I saw light at the end of the tunnel!

Comparing with the traditional way, In VS I had to create the right hierarchy of folders one by one so the include files path don’t change. In the case of a huge library, that’s really unnecessary.

Other stuff I didn’t find inside the project config is the CFLAGS variable. Where is it? how do I declare it?

Hello Xertz,

CFLAGS are additional switches passed to the compiler. You can add them on the project properties -> C/C++ -> Command Line page in the Additional Options textbox.

Thanks Dmitry!

I’ll now try to add gnu++0X to my project. Do I add it as “-std=gnu++0x”?

Hello Xertz,

Yes, exactly, just add the line to the C/C++ properties -> Command Line. According to the GCC docs you may write -std=c++0x or -std=gnu++0x for any GCC version (including 4.7+) that supports the standard as well as -std=c++11 or -std=gnu++11 for GCC 4.7+

Thanks a lot Dmitry!