Issue
I am trying to include my prebuilt library on the existing Android Module art/runtime/
. I have followed the official documentation, found here. In detail, these are the changes I 've made:
Added lines in art/Android.mk:
# This makes sure my library's .mk is found
include $(art_path)/mylib/Android.mk
Added lines in art/runtime/Android.mk:
# Added this, after the LOCAL_C_INCLUDES
LOCAL_STATIC_LIBRARIES := mylib-prebuilt
# Also, on the next mention of LOCAL_STATIC_LIBRARIES, I changed the
# assignment operator to '+=', so mylib won't overriden
Include in art/runtime.cc
source mylib's header:
#include "mylib.h"
// then at some point use it
I have put mylib
sources in art/mylib
. I manually build, using a regular Makefile, the archive libmylib.a
, which I want to be statically linked to libart.so
.
In the Android.mk found at art/mylib
I have added the following:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib-prebuilt
LOCAL_SRC_FILES := $(LOCAL_PATH)/libmylib.a
LOCAL_EXPORT_C_INCLUDES := \
$(LOCAL_PATH)/mylib.h \
$(LOCAL_PATH)/another_header.h
include $(PREBUILT_STATIC_LIBRARY)
By exporting the C includes, the dependent modules should have automatically appended them to their local list. However, this is not the case, as I get the error:
fatal error: 'mylib.h' file not found
If I workaround this issue, with a stupid way that I really shouldn't, I stumble upon a link error, as my libmylib.a
is never used during linking.
Other information:
I have placed mylib
in art/mylib
as it will be part of the art namespace
and its methods will be calling/being called by art/runtime
sources, e.g. runtime.cc
. I have chosen to go with prebuilt-libraries
, instead of directly including my sources, like Garbage Collector (found at art/runtime/gc`), as I want to pass particular compilation flags to individual source files.
I have already tried, and failed, solutions to other questions, found here and here.
Any thoughts?
EDIT: When I try to make a full build, I get the following error:
make: *** No rule to make target 'out/host//obj/STATIC_LIBRARIES/mylib-prebuilt_intermediates/export_includes', needed by 'out/host//obj/EXECUTABLES/dex2oat_intermediates/import_includes'. Stop.
Thanks!
Solution
I finally managed to get this to work.
My library is now placed at art/runtime/mylib
.
In art/runtime/Android.mk
, I include the sources with:
LOCAL_C_INCLUDES += art/runtime/mylib
This makes mylib.h
visible to the runtime source files.
The art/runtime/mylib/Android.mk
has changed almost completely to:
LOCAL_MODULE := libmylib
LOCAL_SRC_FILES := libmylib.a
LOCAL_MODULE_SUFFIX := .a
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
include $(BUILD_PREBUILT)
In my previous attempts, LOCAL_EXPORT_C_INCLUDES
, in contrary to documentation, it didn't copy files to the dependent modules. Also PREBUILT_STATIC_LIBRARY
didn't seem to be working.
Now, I can build my library in an archive of objects, using regular makefiles, and the build system copies it each time it gets changed to the appropriate locations, so at the link stage can be blended with libart.so
.
Answered By - Paschalis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.