w3u37905
w3u37905

Reputation: 37

Android NDK: build my static library

I have these files in jni folder:

and I just want to use my library in resolution.cpp like:

#include"m_lanczos.h"

What else do I have to add in Android.mk? Thank you!

 LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := super
LOCAL_SRC_FILES := sresolution.cpp 
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)

Upvotes: 2

Views: 2285

Answers (1)

bricklore
bricklore

Reputation: 4165

There are two things that could be wrong:

  1. You have forgot to compile m_lanczos.c:
    Then your Android.mk should look like this:

    LOCAL_PATH := $(call my-dir)  
    include $(CLEAR_VARS)  
    
    LOCAL_MODULE := super  
    LOCAL_SRC_FILES := sresolution.cpp m_lanczos.c  
    LOCAL_LDLIBS +=  -llog -ldl  
    
    include $(BUILD_SHARED_LIBRARY)  
    
  2. m_lanczos is a STATIC_LIBRARY:
    Then you have to build it and include it:

    LOCAL_PATH := $(call my-dir) 
    
    include $(CLEAR_VARS)       
    LOCAL_MODULE := m_lanczos
    LOCAL_SRC_FILES := m_lanczos.c  
    LOCAL_LDLIBS +=           #needed librarys for m_lanczos, probably nothing       
    include $(BUILD_STATIC_LIBRARY) 
    
    include $(CLEAR_VARS)         
    LOCAL_MODULE := super  
    LOCAL_SRC_FILES := sresolution.cpp
    LOCAL_LDLIBS +=  -llog -ldl  
    LOCAL_STATIC_LIBRARIES := m_lanczos
    include $(BUILD_SHARED_LIBRARY)
    

But i think it will be the first one, i hope that i helped :)

Upvotes: 1

Related Questions