Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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.
Posted
Comments
Richard MacCutchan 19-Jul-12 9:31am    
The error message could not be more clear, the file exp.h cannot be found. Where is this file stored, in your public system library, in your project folder, in some other folder?
subrata kumar Nayak 19-Jul-12 23:10pm    
thanks fr ur comment, I am having the file exp.h in the libtest.a.....
since i am including the library so i think tht i don't need to give the path of the file "exp.h"

1 solution

just add the line
LOCAL_EXPORT_C_INCLUDES := pathto/folder (where my file resides)
above the
include $(PREBUILT_STATIC_LIBRARY)



and my final .mk file became like this:

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)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900