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/?
You must not link against non-NDK platform libraries.
As see from https://android.googlesource.com/platform/bionic/+/372f19e9e27c1333c0fc1e83b53d365051e81612/android-changes-for-ndk-developers.md
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. :)