我在Windows上使用NDK-r6,并希望为测试目的编译一个简单的C程序。仅仅编译一个C控制台程序并不是那么容易,但我得到了所需的选项。我使用的命令行是(在cygwin中):
/cygdrive/f/android/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc
-fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__
-D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te
-mtune=xscale -msoft-float -mthumb -Os -funroll-all-loops -fomit-frame-pointer
-fno-strict-aliasing -finline-limit=64 -IF:/android_ws/stkeys/jni -DANDROID
-Wa,--noexecstack -O3 -DNDEBUG -g -Wl,
-rpath-link=/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib
-L/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib -nostdlib
/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o
-lc -IF:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include
F:/android_ws/stkeys/jni/stkeys.c F:/android_ws/stkeys/jni/sha1.c
-o F:/android_ws/stkeys/jni/stkeys一个地狱的命令行,但它是有效的。问题是,这段代码破坏了:
#ifndef uint32_t
typedef unsigned int uint32_t;
#endif
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif以下是错误:
In file included from F:/android_ws/stkeys/jni/stkeys.c:44:
F:/android_ws/stkeys/jni/sha1.h:23: error: redefinition of typedef 'uint32_t'
F:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include/stdint.h:53:
note: previous declaration of 'uint32_t' was here
F:/android_ws/stkeys/jni/sha1.h:27: error: redefinition of typedef 'uint8_t'
F:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include/stdint.h:49:
note: previous declaration of 'uint8_t' was here我通过在stdint.h中注释掉uint32_t等的定义来编译它,但这不可能是解决方案。这是NDK的错误,还是我做错了什么?
发布于 2011-08-14 09:54:47
很明显,它并不期望stdint.h会被包括在内。不知道为什么。
测试#ifndef只适用于某些东西是#defined的情况下的测试。没有办法有条件地执行typedef的测试。
我宁愿破解应用程序代码,也不愿破解标准头。:-)
https://stackoverflow.com/questions/7054962
复制相似问题