Reputation: 167
I am trying to access libsparese library in my binary which is present in vendor partition, but libsparse library is in system partition,During building it is throwing the below error.
(native:vendor) should not link to libsparse (native:platform)
How can I use that library, if it is present in system/lib64/?
Upvotes: 7
Views: 12790
Reputation: 49
This is just for additional info.
If the system library which you are using, is built from your own code then you can make the system library as vendor compatible by adding the below flags in either Android.mk
or Android.bp
.
For Android.bp
:
vendor_available: true
For Android.mk
:
LOCAL_VENDOR_MODULE := true
Now you can include these libs in SHARED_LIBRARIES
and use these.
Upvotes: 1
Reputation: 167
if your module is dependent on any system module then you can follow below steps to link your module to system module.
Example :- module A is a vendor platform module module B is a system platform module and you are getting below error after include the module B in your module A. module A (native:vendor) should not link to module B (native:platform) then.................. There is a work around for that..
Add module B absolute path in "LOCAL_C_INCLUDES+=" of module A make file. LOCAL_C_INCLUDES += \ /system//include
is the Module B is shared library then add below in module A make file. LOCAL_LDFLAGS += $(call intermediates-dir-for,SHARED_LIBRARIES,B)/B.so
At last add additional dependency for module B in module A LOCAL_ADDITIONAL_DEPENDENCIES := B
Now you can use module B in module A. :)
Upvotes: 2
Reputation: 12583
You must not link against non-NDK platform libraries.
Native libraries must use only public API, and must not link against non-NDK platform libraries. Starting with API 24 this rule is enforced and applications are no longer able to load non-NDK platform libraries. The rule is enforced by the dynamic linker, so non-public libraries are not accessible regardless of the way code tries to load them: System.loadLibrary, DT_NEEDED entries, and direct calls to dlopen(3) will all work exactly the same.
Upvotes: 1