Prebuild of static library failed

190 views
Skip to first unread message

hellho...@web.de

unread,
May 21, 2013, 5:37:32 AM5/21/13
to andro...@googlegroups.com
After I solved my issues of this thread https://groups.google.com/forum/?hl=de&fromgroups#!topic/android-ndk/edlkUhzJkAQ
I've decided to open a new thread with a prebuild issue (and additional informations) which I could not solve until yet:

I try to set up an Android NDK build based on CMake scripts, which dynamically create the required Android make files.
While I can't use the JNI folder structure I split the build process in several separated make scripts:

1st Create root Android.mk file located in project root:

    #ANDROID ROOT MAKEFILE

    LOCAL_PATH := D:/binrev/repository/bar
    include $(CLEAR_VARS)

    MY_LOCAL_CFLAGS := -DDEBUG
    include D:/binrev/repository/bar/src/Android.mk


2nd Create source Android.mk file in project source folder and perform module build:

    $(info "[INFO] Source Makefile invoked")

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

    LOCAL_MODULE    := bar
    LOCAL_C_INCLUDES:= D:/binrev/repository/bar/include
    LOCAL_SRC_FILES :=  bar.cpp

    ifeq (debug,"debug")
       MY_LOCAL_CFLAGS := -DDEBUG
    endif

    ifeq (false,true)
       LOCAL_ARM_MODE := arm
    endif
     
    LOCAL_EXPORT_C_INCLUDES := D:/binrev/repository/bar/include

    LOCAL_LDLIBS := -llog
    LOCAL_LDLIBS += -landroid

    LOCAL_STATIC_LIBRARIES += foo

    ifeq (OFF, ON)
       include $(BUILD_SHARED_LIBRARY)
    else
       include $(BUILD_STATIC_LIBRARY)
    endif

Basicly this mechanism works and I could compile my sources, but I fail if I try to include a Prebuild of a library. I tried the following ways to include a pre-build
of a static library (with modified source/include definitions):

    include $(CLEAR_VARS)
    LOCAL_MODULE := foo
    LOCAL_SRC_FILES := lib/android/$(TARGET_ARCH_ABI)/libfoo.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)

1st Prebuild definition in source Android.mk file
2nd Call import-module mechanism and add Prebuild Android.mk file to prebuild-lib
3rd Prebuild definition in root Android.mk file

Here is the snipped of the call-import test which also fail:

    $(info "[INFO] Source Makefile invoked")

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

    LOCAL_MODULE    := bar
    LOCAL_C_INCLUDES:= D:/binrev/repository/bar/include
    LOCAL_SRC_FILES :=  bar.cpp

    ifeq (debug,"debug")
        MY_LOCAL_CFLAGS := -DDEBUG
    endif

    ifeq (false,true)
        LOCAL_ARM_MODE := arm
    endif
     
    LOCAL_EXPORT_C_INCLUDES := D:/binrev/repository/bar/include

    LOCAL_LDLIBS := -llog
    LOCAL_LDLIBS += -landroid

    LOCAL_STATIC_LIBRARIES += foo

    ifeq (ON, ON)
       include $(BUILD_SHARED_LIBRARY)
    else
       include $(BUILD_STATIC_LIBRARY)
    endif

    $(call import-module, external-deps/foo)

In each case the Script with the prebuild-definition is invoked, but the prebuild
is not performed. When my NDK build has been compleded, the prebuild library and
objects are not copied to my obj folder. It seems to me that the prebuild is
completely ignored. But the path to prebuild sources are correct, otherwise the
compile fails with missing file error.

You could get the complete source of this test implementation here:
https://sourceforge.net/projects/binrevengine/files/publications/

Hint: The bar project is the shared lib project which tries to prebuild the static foo project.
        The foo project contains the prebuild sources.

The added tests projects could be build by your own using MinGW64 with GCC 4.7/4.8 in handshake with CMake and pre installed NDK (using r8e).

I completly get lost and running out of ideas ...
Thanks for any help.

hellho...@web.de

unread,
May 22, 2013, 5:03:42 AM5/22/13
to andro...@googlegroups.com
To exclude possible sources of defects I've reduced the Android make file to simplest case without using CMake generator of those files:


LOCAL_PATH := D:/binrev/repository/bar
include $(CLEAR_VARS)

LOCAL_MODULE    := foo-prebuilt
LOCAL_SRC_FILES := external-deps/foo/lib/android/$(TARGET_ARCH_ABI)/libfoo.a
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)           
LOCAL_MODULE    := bar
LOCAL_C_INCLUDES:= D:/binrev/repository/bar/include
LOCAL_C_INCLUDES+= D:/binrev/repository/bar/external-deps/foo/include
LOCAL_SRC_FILES := src/bar.cpp


LOCAL_LDLIBS := -llog
LOCAL_LDLIBS += -landroid 
 
LOCAL_SHARED_LIBRARIES := foo-prebuilt
include $(BUILD_SHARED_LIBRARY)

and:

LOCAL_PATH := D:/binrev/repository/foo

include $(CLEAR_VARS)

LOCAL_MODULE    := foo
LOCAL_C_INCLUDES:= D:/binrev/repository/foo/include
LOCAL_SRC_FILES := src/foo.cpp


LOCAL_LDLIBS := -llog
LOCAL_LDLIBS += -landroid 
 
include $(BUILD_STATIC_LIBRARY)

The failure still exists. The prebuild of the foo library is not executed. I also excluded MinGW64 as possible source of defect,
if I try to build the project with Windows command line it results in same issue. The shared library is build, but the prebuild
is not executed.

I checked my sources and scripts multiple times, but can't find any failure.
Any ideas what could be wrong or missing?

David Turner

unread,
May 22, 2013, 6:12:03 AM5/22/13
to andro...@googlegroups.com
What do you mean by "the prebuild is not executed". A prebuilt library doesn't do anything by itself. It's only a link time that it becomes useful.
In the case of prebuilt static libraries, the NDK no longer copies them to the obj/local/ directory since the link command can directly reference the file.

Are you saying that the link command doesn't use the prebuilt library? What is the output of using NDK_LOG=1 NDK_DEBUG_MODULES=1, these will print what ndk-build is build the module database before executing commands.
 
I checked my sources and scripts multiple times, but can't find any failure.
Any ideas what could be wrong or missing?


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

hellho...@web.de

unread,
May 22, 2013, 7:36:25 AM5/22/13
to andro...@googlegroups.com

In the case of prebuilt static libraries, the NDK no longer copies them to the obj/local/ directory since the link command can directly reference the file.

Thanks for the hint, this was the information I've missed. Related to the android documentation I've expected that prebuild should copy the library to obj folder. Foo is linked correctly:

   foo:
       MODULE: foo
       MODULE_FILENAME: libfoo
       PATH: D:/binrev/repository/bar
       C_INCLUDES: D:/binrev/repository/bar/external-deps/foo/include
       EXPORT_C_INCLUDES: D:/binrev/repository/bar/external-deps/foo/include
       MAKEFILE: /d/binrev/repository/bar/external-deps/foo/Android.mk
       BUILT_MODULE: D:/binrev/repository/bar/external-deps/foo/lib/android/armabi-v7a/libfoo.a
       OBJS_DIR: ./obj/local/armeabi-v7a/objs-debug/foo
       MODULE_CLASS: PREBUILT_STATIC_LIBRARY

hellho...@web.de

unread,
May 22, 2013, 7:45:01 AM5/22/13
to andro...@googlegroups.com
Additional question. Is the prebuild library also not copied if I use the call import-module mechanism?
I've seen that the native_app_glue library is copied, but mine not ...

David Turner

unread,
May 22, 2013, 10:57:15 AM5/22/13
to andro...@googlegroups.com
On Wed, May 22, 2013 at 1:45 PM, Hellho...@web.de <hellho...@web.de> wrote:
Additional question. Is the prebuild library also not copied if I use the call import-module mechanism?

Nope
 
I've seen that the native_app_glue library is copied, but mine not ...

native_app_glue is not a prebuilt, it is compiled and the object files are placed in your obj/local/ directory. :-) 
Reply all
Reply to author
Forward
0 new messages