Re: Change default binaries output folder (libs and obj)

4,549 views
Skip to first unread message

David Turner

unread,
Apr 25, 2013, 3:27:13 AM4/25/13
to andro...@googlegroups.com



On Thu, Apr 25, 2013 at 12:40 AM, <rusek.p...@gmail.com> wrote:
Hi everyone, I'm trying to change default output folder for libs and obj folders. I know there is (undocummented) NDK_APP_OUT that I can override in Application.mk script that will change default obj folder location.

Actually you should use NDK_OUT, which is officially supported. It's only documented on the CHANGES.html file though, we should probably update NDK-BUILD.html as well :-)
 
I was trying to find a way to also change libs folder.
I know I may create build script that copies/moves this folder after build but I don't like such solutions.
I have actually two questions:
1) Is there a way to change default libraries output folder (libs)?
2) Does NDK_APP_OUT is something that is free to use by everyone? If yes then I have a kind request to document it somewhere in docs


The completely-unofficial / might break in the future way is to override NDK_APP_DST_DIR on the command line (e.g. ndk-build NDK_APP_DST_DIR=<path> <other-options>)
but this forces _all_ binaries to be copied to the same location (i.e. this overrides $PROJECT_PATH/libs/$ABI/ completely). That's not going to work if you target several ABIs.

As an alternative, consider modifying build/core/setup-toolchain.mk where it is defined. Or file a feature request on b.android.com
 
BTW. I'm using NDK r8e.
Thanks for any reply!

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

rusek.p...@gmail.com

unread,
Apr 25, 2013, 5:04:51 PM4/25/13
to andro...@googlegroups.com
That's great answer, thank you very much!
I created a feature request here

Alex Cohn

unread,
May 1, 2013, 3:42:58 AM5/1/13
to andro...@googlegroups.com
On Thursday, April 25, 2013 1:40:35 AM UTC+3, rusek.p...@gmail.com wrote:
Hi everyone, I'm trying to change default output folder for libs and obj folders. I know there is (undocummented) NDK_APP_OUT that I can override in Application.mk script that will change default obj folder location. I was trying to find a way to also change libs folder.
I know I may create build script that copies/moves this folder after build but I don't like such solutions.
I have actually two questions:
1) Is there a way to change default libraries output folder (libs)?

What are you trying to achieve this way? You need the native libraries in libs/$(ABI) folder so that they get packed into the APK and extracted/deployed by the installer from the APK on the target device.

Alex

rusek.p...@gmail.com

unread,
May 1, 2013, 4:50:29 AM5/1/13
to andro...@googlegroups.com
Hi Alex,

I have separate projects for various native libraries. Theirs output should go into separate directory and then they should be packed into APK from another project. Android is not my only target and I want it to fit my current directory tree. Please take a look into my directory tree I've attached in a future request.

Cheers!
Paweł Rusek

rusek.p...@gmail.com

unread,
May 3, 2013, 5:02:06 AM5/3/13
to andro...@googlegroups.com
 Digit:

The completely-unofficial / might break in the future way is to override NDK_APP_DST_DIR on the command line (e.g. ndk-build NDK_APP_DST_DIR=<path> <other-options>) 
but this forces _all_ binaries to be copied to the same location (i.e. this overrides $PROJECT_PATH/libs/$ABI/ completely). That's not going to work if you target several ABIs. 

Actually if your NDK_APP_DST_DIR or module name ends with $(TARGET_ARCH_ABI) then there is no conflict :)

Alex Cohn

unread,
May 5, 2013, 8:15:48 AM5/5/13
to andro...@googlegroups.com
Hi Paweł,

From your diagram it is not clear, where you put Application,mk file (or files). The basic idea of ndk-build is that all your components represent one Application, therefore they all share one Application.mk and some common settings (APP_CFLAGS, APP_STL, etc). In your Output/Binaries, do you want to keep the .SO files, or .APK files?

Alex

rusek.p...@gmail.com

unread,
May 5, 2013, 6:33:36 PM5/5/13
to andro...@googlegroups.com
I'm putting each Application.mk into jni folders (one for each project).
Two of my projects are only creating .so files. Third project takes those .so files, creates another one and packing them all to .apk file. I've created separate projects because those .so files will be shared among other projects.
In Output folder I want to put .so files.

Alex Cohn

unread,
May 6, 2013, 3:05:46 PM5/6/13
to andro...@googlegroups.com
On Monday, May 6, 2013 1:33:36 AM UTC+3, rusek.p...@gmail.com wrote:
I'm putting each Application.mk into jni folders (one for each project).

I believe that it's much safer to use a single Application.mk file and essentially to build all three .SO files (* number of supported ABIs) in one  ndk-build step. The main concern is that APP_* settings should match if you want to safely use the  resulting .SO files in one APK. Actually, Application.mk file is optional. You don't need it if no application-wide settings are imposed.

Two of my projects are only creating .so files. Third project takes those .so files, creates another one and packing them all to .apk file. I've created separate projects because those .so files will be shared among other projects.

It's enough to have separate Android.mk files to build each project.
 
In Output folder I want to put .so files.

I do it in a very simple way: I simply define an extra target in my Android.mk file, which depends on the installed .SO file, and copies it to whereverI  need it, e.g.

../out/arm/libEngine.so: libs/armeabi/libEngine.so
$(call host-cp,$<,$@)

rusek.p...@gmail.com

unread,
May 6, 2013, 5:48:15 PM5/6/13
to andro...@googlegroups.com
On Monday, May 6 2013 21:05:46 UTC+2, Alex Cohn wrote:

I believe that it's much safer to use a single Application.mk file and essentially to build all three .SO files (* number of supported ABIs) in one  ndk-build step. The main concern is that APP_* settings should match if you want to safely use the  resulting .SO files in one APK. Actually, Application.mk file is optional. You don't need it if no application-wide settings are imposed.

Yes, I agree it is much safer. and for this particular case I've shown one Android Project would be most probably a better solution, nevertheless it is cool option to be able to split them into separate projects. I've just finished setting up my projects and this setup is working really fine. Now I can easly add new project in the workspace that would be dependent on engine and math lib without modifying any master makefile. This is because project's output is in some generic output folder by changing NDK_APP_DST_DIR at ndk-build call.

Both solutions has theirs cons and pros. I'm not saying that mine solution is the best and everyone should follow it. Moreover I think making one project is much better solution in most cases. I like my way, because it fits in my workflow.
Reply all
Reply to author
Forward
0 new messages