我有一个简单的Android.mk文件,用于构建libpng,我从AOSP中获取并略微修改以构建共享库而不是静态库。
LOCAL_PATH:= $(call my-dir)
LOCAL_CFLAGS :=
LOCAL_COPY_HEADERS_TO := libs/include
LOCAL_COPY_HEADERS := \
png.h \
pngconf.h \
pngusr.h
LOCAL_SRC_FILES := \
png.c \
pngerror.c \
pnggccrd.c \
pngget.c \
pngmem.c \
pngpread.c \
pngread.c \
pngrio.c \
pngrtran.c \
pngrutil.c \
pngset.c \
pngtrans.c \
pngvcrd.c \
pngwio.c \
pngwrite.c \
pngwtran.c \
pngwutil.c
LOCAL_LDLIBS := -lz
LOCAL_MODULE := png
LOCAL_MODULE_FILENAME := libpng
include $(BUILD_SHARED_LIBRARY)
LOCAL_COPY_HEADERS_TO和LOCAL_COPY_HEADERS选项似乎应该将指定的标题复制到libs / include目录......但它们不会做任何事情。图书馆本身似乎正确构建。我正在为ndk-build使用详细输出,并且没有错误。这是我使用的命令(我刚刚添加了转义符,因此命令更容易阅读):
ndk-build \
NDK_PROJECT_PATH=. \
APP_BUILD_SCRIPT=Android.mk \
TARGET_ARCH_ABI=armeabi-v7a \
TARGET_PLATFORM=android-9 \
V=1 NDK_LOG=1 -B
这是构建输出。请注意,最后安装仅在lib二进制文件上调用。
HOST_OS=linux
HOST_ARCH=x86_64
HOST_TAG=linux-x86_64
GNUMAKE=/home/preet/Dev/env/sys/android-ndk-r8e/prebuilt/linux-x86_64/bin/make (NDK prebuilt)
Android NDK: NDK installation path auto-detected: '/home/preet/Dev/env/sys/android-ndk-r8e'
Android NDK: GNU Make version 3.81 detected
Android NDK: Host OS was auto-detected: linux
Android NDK: Host operating system detected: linux
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to linux-x86
Android NDK: Host tools prebuilt directory: /home/preet/Dev/env/sys/android-ndk-r8e/prebuilt/linux-x86_64/bin
Android NDK: Host 'echo' tool: echo
Android NDK: Host 'echo -n' tool: printf %s
Android NDK: Host 'cmp' tool: cmp
Android NDK: Host 'awk' tool: /home/preet/Dev/env/sys/android-ndk-r8e/prebuilt/linux-x86_64/bin/awk
Android NDK: Host 'awk' test returned: Pass
Android NDK: Found platform root directory: /home/preet/Dev/env/sys/android-ndk-r8e/platforms
Android NDK: Found supported platforms: android-14 android-3 android-4 android-5 android-8 android-9
Android NDK: PLATFORM android-14 supports: arm mips x86
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-14/arch-arm
Android NDK: ABI mips sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-14/arch-mips
Android NDK: ABI x86 sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-14/arch-x86
Android NDK: PLATFORM android-3 supports: arm
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-3/arch-arm
Android NDK: PLATFORM android-4 supports: arm
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-4/arch-arm
Android NDK: PLATFORM android-5 supports: arm
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-5/arch-arm
Android NDK: PLATFORM android-8 supports: arm
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-8/arch-arm
Android NDK: PLATFORM android-9 supports: arm mips x86
Android NDK: ABI arm sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm
Android NDK: ABI mips sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-mips
Android NDK: ABI x86 sysroot is: /home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-x86
Android NDK: Found stable platform levels: 14 3 4 5 8 9
Android NDK: Found max platform level: 14
Android NDK: This NDK supports the following target architectures and ABIS:
Android NDK: arm: armeabi armeabi-v7a
Android NDK: mips: mips
Android NDK: x86: x86
Android NDK: This NDK supports the following toolchains and target ABIs:
Android NDK: arm-linux-androideabi-4.4.3: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-4.6: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-4.7: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-clang3.1: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-clang3.2: armeabi armeabi-v7a
Android NDK: mipsel-linux-android-4.4.3: mips
Android NDK: mipsel-linux-android-4.6: mips
Android NDK: mipsel-linux-android-4.7: mips
Android NDK: mipsel-linux-android-clang3.1: mips
Android NDK: mipsel-linux-android-clang3.2: mips
Android NDK: x86-4.4.3: x86
Android NDK: x86-4.6: x86
Android NDK: x86-4.7: x86
Android NDK: x86-clang3.1: x86
Android NDK: x86-clang3.2: x86
Android NDK: Found project path: .
Android NDK: Ouput path: ./obj
Android NDK: Parsing /home/preet/Dev/env/sys/android-ndk-r8e/build/core/default-application.mk
Android NDK: Defaulted to APP_PLATFORM=android-3
Android NDK: APP_PIE is
Android NDK: Using build script Android.mk
Android NDK: Application 'local' is not debuggable
Android NDK: Selecting release optimization mode (app is not debuggable)
Android NDK: Adding import directory: /home/preet/Dev/env/sys/android-ndk-r8e/sources
Android NDK: Building application 'local' for ABI 'armeabi-v7a'
Android NDK: Using target toolchain 'arm-linux-androideabi-4.6' for 'armeabi-v7a' ABI
Android NDK: Looking for imported module with tag 'cxx-stl/system'
Android NDK: Probing /home/preet/Dev/env/sys/android-ndk-r8e/sources/cxx-stl/system/Android.mk
Android NDK: Found in /home/preet/Dev/env/sys/android-ndk-r8e/sources/cxx-stl/system
rm -f ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/mips/lib*.so ./libs/x86/lib*.so
rm -f ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/mips/gdbserver ./libs/x86/gdbserver
rm -f ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/mips/gdb.setup ./libs/x86/gdb.setup
Compile thumb : png <= png.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/png.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./png.c -o ./obj/local/armeabi-v7a/objs/png/png.o
Compile thumb : png <= pngerror.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngerror.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngerror.c -o ./obj/local/armeabi-v7a/objs/png/pngerror.o
Compile thumb : png <= pnggccrd.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pnggccrd.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pnggccrd.c -o ./obj/local/armeabi-v7a/objs/png/pnggccrd.o
Compile thumb : png <= pngget.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngget.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngget.c -o ./obj/local/armeabi-v7a/objs/png/pngget.o
Compile thumb : png <= pngmem.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngmem.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngmem.c -o ./obj/local/armeabi-v7a/objs/png/pngmem.o
Compile thumb : png <= pngpread.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngpread.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngpread.c -o ./obj/local/armeabi-v7a/objs/png/pngpread.o
Compile thumb : png <= pngread.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngread.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngread.c -o ./obj/local/armeabi-v7a/objs/png/pngread.o
Compile thumb : png <= pngrio.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngrio.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngrio.c -o ./obj/local/armeabi-v7a/objs/png/pngrio.o
Compile thumb : png <= pngrtran.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngrtran.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngrtran.c -o ./obj/local/armeabi-v7a/objs/png/pngrtran.o
Compile thumb : png <= pngrutil.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngrutil.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngrutil.c -o ./obj/local/armeabi-v7a/objs/png/pngrutil.o
Compile thumb : png <= pngset.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngset.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngset.c -o ./obj/local/armeabi-v7a/objs/png/pngset.o
Compile thumb : png <= pngtrans.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngtrans.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngtrans.c -o ./obj/local/armeabi-v7a/objs/png/pngtrans.o
Compile thumb : png <= pngvcrd.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngvcrd.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngvcrd.c -o ./obj/local/armeabi-v7a/objs/png/pngvcrd.o
Compile thumb : png <= pngwio.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngwio.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngwio.c -o ./obj/local/armeabi-v7a/objs/png/pngwio.o
Compile thumb : png <= pngwrite.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngwrite.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngwrite.c -o ./obj/local/armeabi-v7a/objs/png/pngwrite.o
Compile thumb : png <= pngwtran.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngwtran.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngwtran.c -o ./obj/local/armeabi-v7a/objs/png/pngwtran.o
Compile thumb : png <= pngwutil.c
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi-v7a/objs/png/pngwutil.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I. -DANDROID -Wa,--noexecstack -I/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/include -c ./pngwutil.c -o ./obj/local/armeabi-v7a/objs/png/pngwutil.o
SharedLibrary : libpng.so
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libpng.so -shared --sysroot=/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm ./obj/local/armeabi-v7a/objs/png/png.o ./obj/local/armeabi-v7a/objs/png/pngerror.o ./obj/local/armeabi-v7a/objs/png/pnggccrd.o ./obj/local/armeabi-v7a/objs/png/pngget.o ./obj/local/armeabi-v7a/objs/png/pngmem.o ./obj/local/armeabi-v7a/objs/png/pngpread.o ./obj/local/armeabi-v7a/objs/png/pngread.o ./obj/local/armeabi-v7a/objs/png/pngrio.o ./obj/local/armeabi-v7a/objs/png/pngrtran.o ./obj/local/armeabi-v7a/objs/png/pngrutil.o ./obj/local/armeabi-v7a/objs/png/pngset.o ./obj/local/armeabi-v7a/objs/png/pngtrans.o ./obj/local/armeabi-v7a/objs/png/pngvcrd.o ./obj/local/armeabi-v7a/objs/png/pngwio.o ./obj/local/armeabi-v7a/objs/png/pngwrite.o ./obj/local/armeabi-v7a/objs/png/pngwtran.o ./obj/local/armeabi-v7a/objs/png/pngwutil.o -lgcc -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -L/home/preet/Dev/env/sys/android-ndk-r8e/platforms/android-9/arch-arm/usr/lib -lz -lc -lm -o ./obj/local/armeabi-v7a/libpng.so
Install : libpng.so => libs/armeabi-v7a/libpng.so
install -p ./obj/local/armeabi-v7a/libpng.so ./libs/armeabi-v7a/libpng.so
/home/preet/Dev/env/sys/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded ./libs/armeabi-v7a/libpng.so
答案 0 :(得分:0)
LOCAL_COPY_HEADERS := \
png.h \
pngconf.h \
pngusr.h
接下来是:
LOCAL_COPY_HEADERS_TO := libs/include
(你必须指示你的标题,然后告诉系统将它们复制到哪里。)它也可能在你当前的sdk上已被弃用。