简体   繁体   中英

Android NDK, headers from a prebuilt static library

I am having a problem when using a pre-built static library when the compiler is looking for headers.

I have a .cpp that needs to use a header file from a static library. My Android.mk is as followed :

include $(CLEAR_VARS)
LOCAL_MODULE := LibA
LOCAL_SRC_FILES := libs/libA.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := hello
LOCAL_SRC_FILES := hello.cpp 
LOCAL_STATIC_LIBRARIES :=  LibA 
include $(BUILD_SHARED_LIBRARY)

hello.cpp requires a header that can be found in the static library but the compiler says it can't find it. Do I have to have headers seperated from that static library ?

Headers are not included in static libraries. Even if they were, the compiler has no way to read a .a file, only the linker will do that.

I'm not a prof, but I've learned that you allways need a corresponding .h-file included! In those .h-files the compiler gets the info "how to use" the libraries as they defines the functions that are inside the libs.

Good luck Martin

在第二步中尝试“ LOCAL_LDLIBS”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM