Reputation: 405
I'm trying to use a .a file in my C code to use in Java (sorry for my bad English). I created myself a static library named libtest.a
. now when i include files present in that library in gives me error as no such file or directory.
i have put the libtest.a
in the same folder where my Android.mk
and Application.mk
resides
C-code:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <exp.h> //the header in libtest.a
And this is my makefile:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := libtest.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := socket
LOCAL_SRC_FILES := source/interface.c source/file.c
LOCAL_LDFLAGS += libtest.a
include $(BUILD_SHARED_LIBRARY)
When I compile it, I get the following error
error: exp.h: No such file or directory
I want to use the .a without it's code so I hope I'm clear enough.
Upvotes: 2
Views: 3004
Reputation: 405
as i have changed my .mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := libtest.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../libtest/jni/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := socket
LOCAL_SRC_FILES := source/interface.c source/file.c
LOCAL_STATIC_LIBRARIES += libtest
include $(BUILD_SHARED_LIBRARY)
Upvotes: 1
Reputation: 25386
There are no header files in .a file, only the compiled code which is essentially a stream of bytes, not the encoded .h-files . This it NOT Java. To use your libtest.a
you must supply the exp.h
file and whatever the dependent header files are.
You should use LOCAL_STATIC_LIBRARIES
for that.
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := libtest.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := socket
LOCAL_SRC_FILES := source/interface.c source/file.c
LOCAL_STATIC_LIBRARIES += libtest
include $(BUILD_SHARED_LIBRARY)
Upvotes: 1