Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C JNI Android makefile
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 19-Jul-12 2:36am
Comments
Richard MacCutchan at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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)
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 23 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100