Can't create shared library with static inside

后端 未结 3 646
误落风尘
误落风尘 2020-12-10 21:32

Please help I search throw whole internet but I can\'t find answer ...

C Layer

I have created simple function int mean(int, int); and place i

3条回答
  •  爱一瞬间的悲伤
    2020-12-10 22:04

    Here is what I did to build the code successfully:

    1. In your Eclipse Android Project create the folder jni.

    2. Add the files calc_mean.c; calc_mean.h; Test_Library.c and Android.mk to the jni folder

    3. Remove the line #include "Test_Library.h"from the Test_Library.c file. Everything else can stay as it is.

    4. In the cygwin command line go to the root folder of your Eclipse Android project and run ndk-build

    If you want to build your calc_mean also as static library during the ndk-build process then you can change your Android.mk file as follows:

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE           := Test_Archive
    LOCAL_SRC_FILES        := calc_mean.c
    
    # compiler flags.
    LOCAL_LDLIBS   = -lz -lm
    LOCAL_CFLAGS   = -Wall -pedantic -std=c99 -g
    
    include $(BUILD_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE := Test_Library
    LOCAL_STATIC_LIBRARIES := Test_Archive
    LOCAL_SRC_FILES := Test_Library.c
    
    
    include $(BUILD_SHARED_LIBRARY)
    

提交回复
热议问题