Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android.mk #107

Merged
merged 2 commits into from
Feb 15, 2015
Merged

Android.mk #107

merged 2 commits into from
Feb 15, 2015

Conversation

newnon
Copy link
Contributor

@newnon newnon commented Feb 12, 2015

Android.mk for android builds

@vitaut
Copy link
Contributor

vitaut commented Feb 13, 2015

Thanks for the contribution. Would you mind adding a few sentences on how to use this stuff to the Usage section of the docs? I guess Android developers should now this, so there is no need to go into much details, but it might be useful at least to give this more visibility.

@newnon
Copy link
Contributor Author

newnon commented Feb 13, 2015

Yes yo can add info to use you library under Android developer just need to add few lines to their Android.mk
first add
LOCAL_WHOLE_STATIC_LIBRARIES += cppformat_static
second
$(call import-module,{relative path to to cppformat}cppformat)
for me it was $(call import-module,../../cppformat)
and then just normally write in any place #include "format.h"

@vitaut
Copy link
Contributor

vitaut commented Feb 13, 2015

Could you please elaborate a bit or give an example. I've copied cppformat to NDK samples and tried to adapt one of them to use the library, but cannot get it to work:

$ ndk-build
Android NDK: .../android-ndk-r10d/samples/test-libstdc++/jni/Android.mk: Cannot find module with tag '../../cppformat' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?

Setting NDK_MODULE_PATH gives another error:

$ NDK_MODULE_PATH=`pwd` ndk-build
Android NDK: Trying to define local module 'test-libstl' in .../android-ndk-r10d/samples/test-libstdc++/jni/./Android.mk.    
Android NDK: But this module was already defined by .../android-ndk-r10d/samples/test-libstdc++/jni/./Android.mk.

Here's the Andorid.mk file that I use:

LOCAL_WHOLE_STATIC_LIBRARIES += cppformat_static
$(call import-module,../../cppformat)

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := test-libstl
LOCAL_SRC_FILES := test-libstl.cpp
include $(BUILD_EXECUTABLE)

Sorry for naive questions, I haven't used NDK before.

@newnon
Copy link
Contributor Author

newnon commented Feb 13, 2015

Here is mine

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := cppformat_static
include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)
$(call import-module,../../cppformat)

$(call import-module,../../cppformat) must be relative to jni folder

"Are you sure your NDK_MODULE_PATH variable is properly defined" - it look like you path is wrong
P.S i'm not sure but may be string order?

P.P.S
my folder structure

Game
    cppformat
    proj.android
        jni

@vitaut
Copy link
Contributor

vitaut commented Feb 15, 2015

I've created a small repository that contains an example of using cppformat with Android NDK: https://github.com/cppformat/android-ndk-example

Unfortunately it doesn't work yet - I get various errors when trying to build it. Could you by any chance have a look at it and tell me what I'm doing wrong? Since you have much more experience in Android development, you'll probably see what's wrong straight away while it will take me ages to figure it out. I'm using this script for building which simply runs ndk-build, but can be extended to set any environment variables (NDK_MODULE_PATH?) if needed.

Thanks!

@newnon
Copy link
Contributor Author

newnon commented Feb 15, 2015

Fixed small bug in Android.mk
and full working demo here https://github.com/newnon/android-ndk-example.git

vitaut added a commit that referenced this pull request Feb 15, 2015
@vitaut vitaut merged commit 11fab45 into fmtlib:master Feb 15, 2015
@vitaut
Copy link
Contributor

vitaut commented Feb 15, 2015

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants