Search code examples
buildandroid-ndkandroid-buildandroid-ndk-r7

can't find libstdc++ when building external modual using gnustl_static


I am adding gnustl_static to a external Android module and when I build it I get the following error.

make: *** No rule to make target `prebuilt/ndk/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libstdc++.a', needed by `out/target/product/msm8960/obj/SHARED_LIBRARIES/liballjoyn_intermediates/LINKED/liballjoyn.so'.  Stop.

when I look under "prebuilt/ndk/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/" I can not find the libstdc++.a there is a fild libsupc++.a

the build system is getting this from the binary.mk file found in the "build/core" folder it states

    # LOCAL_NDK_STL_VARIANT is gnustl_static
my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/include \
                           $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include
my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/libstdc++.a

problem is I don't know what to get past this error.

There are many copies of libstdc++ in the prebuilt folder but they are not found in the location listed. The are found in

prebuild/ndk/$(ANDRIOD_NDK_VERSION)/platforms/$(ANDROID_SDK_VERSION)/$(ARCHETECTURE_TYPE)/usr/lib/libstdc++.a

here is a shortened form of my Android.mk file:

LOCAL_PATH := $(call my-dir)

# Rules to build libabc.so

include $(CLEAR_VARS)

LOCAL_CPP_EXTENSION := .cc

LOCAL_SDK_VERSION := 8
LOCAL_NDK_VERSION := 7
LOCAL_NDK_STL_VARIANT := gnustl_static

LOCAL_CFLAGS += \
        -std=gnu++0x

LOCAL_C_INCLUDES := \
        external/abc/inc \
        external/openssl/include

LOCAL_SRC_FILES := \
        file1.cc \
        file2.cc

LOCAL_SHARED_LIBRARIES := \
        libcrypto \
        libssl \
        liblog

LOCAL_PRELINK_MODULE := false

LOCAL_REQUIRED_MODULES := \
         external/openssl/crypto/libcrypto \
         external/openssl/ssl/libssl

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libabc

include $(BUILD_SHARED_LIBRARY)

Anyone have any ideas how I can solve the "No rule to make target" build issue?


Solution

  • Solution found:

    The simple answer is that I need to change the LOCAL_NDK_VERSION version from 7 to 5 or 6.

    The complex answer is that the binary.mk file has not been updated to account for changes that were made when NDK-7 was released.

    In NDK-5 and NDK-6 when using gnustl_static the library file that contained everything for STL was in libstdc++.a that was located in the location specified in the binary.mk file. When NDK-7 was released the library name was changed from libstdc++.a to libgnustl_static.a. It does not look like the binary.mk was updated to account for this change.

    This is not that surprising since it appears that no projects use gnustl_static. I did a grep accross all of the code in the android repository and the only code I found that was using the LOCAL_NDK_VERSION set to gnustl_static was my own.