2015-08-21 67 views
0

我有一個Application.mk和一個Android.mk文件。Android NDK:可以切換多個庫的APP_STL嗎?

Application.mk看起來像

NDK_TOOLCHAIN_VERSION := 4.8 
APP_PLATFORM := android-9 
APP_STL := c++_shared 
APP_ABI := armeabi-v7a 

和我的Android.mk看起來像

LOCAL_PATH := $(call my-dir) 

include $(CLEAR_VARS) 
LOCAL_MODULE := foo1 
LOCAL_SRC_FILES := foo1.cpp 
# ... some other stuff ... 
include $(BUILD_SHARED_LIBRARY) 

include $(CLEAR_VARS) 
LOCAL_MODULE := foo2 
LOCAL_SRC_FILES := foo2.cpp 
# ... some other stuff ... 
include $(BUILD_SHARED_LIBRARY) 

現在我想該庫libfoo1使用C++ _爲APP_STL和libfoo2使用C++共享靜態_爲APP_STL。 (我知道,通常不應該做成relation between app_stl values with static and shared build android)。有沒有一個簡單的方法,而不建立一個額外的項目,並將庫導入到其他項目?

回答

2

是的,這是可能的。做以下更改:

# Application.mk 
APP_STL := none 

這樣可以禁用選擇NDK構建系統的STL實現的內部邏輯。現在,手動指定您要鏈接的C++ stdlib實現:

# Android.mk 
LOCAL_PATH := $(call my-dir) 

include $(CLEAR_VARS) 
LOCAL_MODULE := foo1 
LOCAL_SRC_FILES := foo1.cpp 
LOCAL_SHARED_LIBRARIES := c++_shared 
# ... some other stuff ... 
include $(BUILD_SHARED_LIBRARY) 

include $(CLEAR_VARS) 
LOCAL_MODULE := foo2 
LOCAL_SRC_FILES := foo2.cpp 
LOCAL_STATIC_LIBRARIES := c++_static 
# ... some other stuff ... 
include $(BUILD_SHARED_LIBRARY) 

$(call import-module,cxx-stl/llvm-libc++) 
相關問題