Android NDK Building Shared Module and including in Android.mk ----- 4

51 views
Skip to first unread message

Mohan Krushna

unread,
May 27, 2021, 3:18:43 PM5/27/21
to android-ndk
├───Common
│   └───ssl
│       ├───include
│       │   ├───crypto
│       │   ├───internal
│       │   └───openssl
│       └───libs
│           ├───arm64-v8a
│           ├───armeabi-v7a
│           ├───x86
│           └───x86_64
Android.mk -------------- (1)
├───GUI
└───SOURCE
    ├───Common
    │   ├───inc
    │   ├───JsonParseMts
    │   │   ├───inc
    │   │   └───src
Android.mk -------------- (2)
    │   └───Utilities
    │       ├───inc
    │       └───src
Android.mk -------------- (3)
    └───L4
        ├───GenMessage_Module
        │   ├───inc
        │   └───src
        └───TxRx
            ├───inc
            └───src
Android.mk -------------- (4)


Android.mk -------------- (1)


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

# SSL
LOCAL_PATH := $(MY_LOCAL_PATH)/libs
LOCAL_MODULE := ssl
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libssl.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

# Crypto
LOCAL_PATH := $(MY_LOCAL_PATH)/libs
LOCAL_MODULE := crypto
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libcrypto.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

Android.mk -------------- (2)


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

# Gen Msg Json parser
LOCAL_PATH := $(MY_LOCAL_PATH)/src
LOCAL_LDLIBS := -llog
LOCAL_MODULE := jsonParseMts
LOCAL_SRC_FILES := cJSON.c jsonParseMts.c
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)
include $(BUILD_SHARED_LIBRARY)


Android.mk -------------- (4)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
MY_LOCAL_PATH := $(LOCAL_PATH)

LOCAL_PATH := $(MY_LOCAL_PATH)/src
LOCAL_LDLIBS := -llog
LOCAL_MODULE := txrx
LOCAL_SRC_FILES := client.c CommonMsg.c
#LOCAL_SHARED_LIBRARIES := ssl crypto utilities jsonParseMts
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/../../../Common/ssl/include $(MY_LOCAL_PATH)/../../Common/JsonParseMts $(MY_LOCAL_PATH)/../../Common/Utilities
include $(BUILD_SHARED_LIBRARY)


MY_LOCAL_PATH := $(LOCAL_PATH)
include $(MY_LOCAL_PATH)/../../../../Common/ssl/Android.mk
MY_LOCAL_PATH := $(LOCAL_PATH)
include $(MY_LOCAL_PATH)/../../../Common/JsonParseMts/Android.mk
MY_LOCAL_PATH := $(LOCAL_PATH)




Error Logs :==

> Task :app:generateJsonModelDebug
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.

> Task :app:generateJsonModelDebug FAILED

Execution failed for task ':app:generateJsonModelDebug'.
> executing external native build for ndkBuild BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk

Alias R. Cummins

unread,
May 27, 2021, 6:10:11 PM5/27/21
to andro...@googlegroups.com
Could you explain the problem in a bit more detail?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/60ad4d43-d670-4284-8d6c-1ca1e60de893n%40googlegroups.com.

Ryan Prichard

unread,
May 27, 2021, 6:21:25 PM5/27/21
to android-ndk
It's trying to include this path and failing:
 
BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk

This path doesn't exist. Simplified it's just:

BestApp5/app/src/main/c/Common/JsonParseMts/Android.mk

It should be:

BestApp5/app/src/main/c/SOURCE/Common/JsonParseMts/Android.mk

I don't think that "include" scopes make variables, so this code seems broken:

MY_LOCAL_PATH := $(LOCAL_PATH)
include $(MY_LOCAL_PATH)/../../../../Common/ssl/Android.mk
MY_LOCAL_PATH := $(LOCAL_PATH)
include $(MY_LOCAL_PATH)/../../../Common/JsonParseMts/Android.mk
MY_LOCAL_PATH := $(LOCAL_PATH)

I would expect the Common/ssl/Android.mk file to set both MY_LOCAL_PATH and LOCAL_PATH, so the attempt to reset MY_LOCAL_PATH (to $(LOCAL_PATH)) afterwards wouldn't actually reset it. Maybe you want to reset MY_LOCAL_PATH using this instead (before each of the include directives):

MY_LOCAL_PATH := $(call my-dir)

-Ryan


Dime Bar

unread,
May 30, 2021, 3:20:55 AM5/30/21
to andro...@googlegroups.com
Hi,

$(MY_LOCAL_PATH)/../../../Common/ssl/include 

Maybe this line is wrong ?

make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'. 

===
'BestApp5/app/src/main/Common/JsonParseMts/Android.mk'.  ?



 Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.
BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:17: BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'BestApp5/app/src/main/c/SOURCE/L4/TxRx/src/../../../../Common/ssl/libs/../../../Common/JsonParseMts/Android.mk'.  Stop.

> Task :app:generateJsonModelDebug FAILED

Execution failed for task ':app:generateJsonModelDebug'.
> executing external native build for ndkBuild BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/60ad4d43-d670-4284-8d6c-1ca1e60de893n%40googlegroups.com.

--
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.

Mohan Krushna

unread,
May 30, 2021, 3:20:59 AM5/30/21
to andro...@googlegroups.com
Hy ryan & cummins

I am trying to build shared library in different folder and trying to connect in android.mk ------(4) as it required the library these ssl crypto island libs are i have build standalone it was successful.but when i am trying to integrate its failing.


This is my complete android.mk(4) files ----------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
MY_LOCAL_PATH := $(LOCAL_PATH)

LOCAL_PATH := $(MY_LOCAL_PATH)/src
LOCAL_LDLIBS := -llog
LOCAL_MODULE := txrx
LOCAL_SRC_FILES := client.c CommonMsg.c
#LOCAL_SHARED_LIBRARIES :=ssl crypto utilities jsonParseMts

LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/../../../Common/ssl/include $(MY_LOCAL_PATH)/../../Common/JsonParseMts $(MY_LOCAL_PATH)/../../Common/Utilities
include $(BUILD_SHARED_LIBRARY)

LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(LOCAL_PATH)

include $(MY_LOCAL_PATH)/../../../../Common/ssl/Android.mk

LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(LOCAL_PATH)

include $(MY_LOCAL_PATH)/../../../Common/JsonParseMts/Android.mk
MY_LOCAL_PATH := $(LOCAL_PATH)
Now its redirecting to  /ndk/21.1.6352462/build//../build/core/
---------------------------------------------------------------
> Task :app:generateJsonModelDebug FAILED
D:\Work\CDAC\SVN\MohanKB\Java_Workspace\BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:18: C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk'.  Stop.
D:\Work\CDAC\SVN\MohanKB\Java_Workspace\BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:18: C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk'.  Stop.
D:\Work\CDAC\SVN\MohanKB\Java_Workspace\BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:18: C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk'.  Stop.
D:\Work\CDAC\SVN\MohanKB\Java_Workspace\BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk:18: C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk: No such file or directory
make: *** No rule to make target 'C:/Users/beher/AppData/Local/Android/Sdk/ndk/21.1.6352462/build//../build/core/../../../Common/JsonParseMts/Android.mk'.  Stop.


Execution failed for task ':app:generateJsonModelDebug'.
> executing external native build for ndkBuild D:\Work\CDAC\SVN\MohanKB\Java_Workspace\BestApp5\app\src\main\c\SOURCE\L4\TxRx\Android.mk


Thanks & regard 
Mohan


You received this message because you are subscribed to a topic in the Google Groups "android-ndk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-ndk/HziK1trDy1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CALgsJznwXCn%3DF_FU2X_p%2BnDh84P4kQOjpXgod9ZzcHL2m5hN0Q%40mail.gmail.com.

Alias R. Cummins

unread,
Jun 1, 2021, 9:02:16 PM6/1/21
to andro...@googlegroups.com
Unfortunately because of legacy limitations of the Windows file system this question is too difficult for me this early in the morning.

A

Alias R. Cummins

unread,
Jun 1, 2021, 9:02:16 PM6/1/21
to andro...@googlegroups.com
I suggest building on Linux or OS X.


Ryan Prichard

unread,
Jun 3, 2021, 5:34:10 PM6/3/21
to android-ndk
Sorry, using $(call my-dir) multiple times isn't going to work either.

https://developer.android.com/ndk/guides/android_mk might be helpful if you haven't found it already. It points out for my-dir:
Due to the way GNU Make works, what this macro really returns is the path of the last makefile that the build system included when parsing the build scripts. For this reason, you should not call my-dir after including another file.

Maybe try import-module? The NDK itself uses that to include Android.mk files from other Android.mk files. e.g.:

android/ndk_helper includes android/cpufeatures:

For your project, I'm not sure what the root directory for import-module is.

llvm-project/libcxx/Android.mk also shows the use of import-add-path to add directories to the search path used by import-module:

It seems import-add-path isn't documented, but import-module is.

-Ryan


Mohan Krushna

unread,
Jun 8, 2021, 10:20:27 PM6/8/21
to andro...@googlegroups.com
yeah i got the solution i have divided the includes path into multiple variables and works fine


--

Thank You,
Mohan Krushna Behera,

Project Associates,
CDAC,NOIDA.

For assimilation and dissemination of knowledge, visit cakes.cdac.in



------------------------------------------------------------------------------------------------------------
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
------------------------------------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages