大家好我想在NDK版本上编译protobuf-2.4.1代码(android-ndk-r8-windows。)
我已经设置如下:
PREBUILT=/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/android-ndk-r8-windows/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3
PLATFORM=/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/android-ndk-r8-windows/android-ndk-r8/platforms/android-4/arch-arm/
export CC="/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/android-ndk-r8-windows/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc"
export CFLAGS="-fPIC -DANDROID -nostdlib"
export ANDROID_ROOT="/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/android-ndk-r8-windows/android-ndk-r8"
export LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-4/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-4/arch-arm/usr/lib/"
export CPPFLAGS="-I$ANDROID_ROOT/platforms/android-4/arch-arm/usr/include/"
CPPFLAGS="-I$ANDROID_ROOT/platforms/android-4/arch-arm/usr/include/"
CPPFLAGS=$CPPFLAGS:"-I$ANDROID_ROOT/sources/cxx-stl/gnu-libstdc++/include/"
export CPPFLAGS
./configure --host=arm-eabi
我在进行NDK构建时遇到以下问题:
In file included from D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:33:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:41:18: error: string: No such file or directory
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:37:18: error: vector: No such file or directory
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:48:2: error: #error "No suitable threading library available."
In file included from D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:33:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:136: error: 'string' in namespace 'std' does not name a type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:647: error: expected unqualified-id before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:647: error: expected ')' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:647: error: 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(...)' must not have variable number of arguments
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:647: error: expected ';' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:663: error: 'string' in namespace 'std' does not name a type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:742: error: expected unqualified-id before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:742: error: expected ')' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:742: error: expected initializer before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.h:757: error: expected constructor, destructor, or type conversion before '*' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In function 'void google::protobuf::internal::VerifyVersion(int, int, const char*)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:62: error: 'VersionString' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:74: error: 'VersionString' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: At global scope:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:84: error: 'string' does not name a type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:108: error: ISO C++ forbids declaration of 'string' with no type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:108: error: expected ',' or '...' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In function 'void google::protobuf::internal::DefaultLogHandler(google::protobuf::LogLevel, const char*, int, int)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:114: error: 'message' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: At global scope:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:119: error: ISO C++ forbids declaration of 'string' with no type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:119: error: expected ',' or '...' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:123: error: expected initializer before '*' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:141: error: ISO C++ forbids declaration of 'string' with no type
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:141: error: expected ',' or '...' before '&' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(int)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:142: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:142: error: 'value' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(const char*)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:147: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(char)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:168: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: At global scope:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:169: error: redefinition of 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(int)'
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:141: error: 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(int)' previously defined here
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(google::protobuf::uint)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:170: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(long int)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:171: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(long unsigned int)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:172: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(double)':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:173: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: In member function 'void google::protobuf::internal::LogMessage::Finish()':
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:190: error: 'log_handler_' is not a member of 'google::protobuf::internal'
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:190: error: 'message_' was not declared in this scope
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc: At global scope:
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:208: error: expected constructor, destructor, or type conversion before '*' token
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:377: error: expected '}' at end of input
D:/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/jni/src/google/protobuf/stubs/common.cc:377: error: expected '}' at end of input
/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/android-ndk-r8-windows/android-ndk-r8/build/core/build-binary.mk:243: recipe for target `/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/obj/local/armeabi/objs/protobuf/src/google/protobuf/stubs/common.o' failed
make: *** [/cygdrive/d/D_Drive/Project/Pr/CCore/Code/NDK/eclipse-SDK-3.7.1-win32/eclipse/workspace/CMNC/obj/local/armeabi/objs/protobuf/src/google/protobuf/stubs/common.o] Error 1
答案 0 :(得分:1)
这来自NDK文档:
C ++ STL支持:
独立工具链还附带了GNU libstdc ++库的副本,该库提供了C ++标准模板库的实现。要使用它,您需要链接到正确的库:
使用-lstdc ++链接静态库版本。这可确保所有必需的C ++ STL代码都包含在最终的二进制文件中。如果您只生成单个共享库或可执行文件,这是理想的选择。 这是推荐的方法。
使用-lgnustl_shared链接共享库版本。如果您有几个相关的共享库或可执行文件需要在运行时在相同的地址空间中运行,则这是必需的(某些全局变量需要唯一定义,如果将静态libstdc ++与每个可执行文件链接起来,这是不可能的)
如果使用此选项,则需要确保libgnustl_shared.so也已复制到您的设备,以便正确加载代码。该文件位于:
$ TOOLCHAIN / arm-linux-androideabi / lib / for ARM toolchains
$ TOOLCHAIN / i686-android-linux / lib / for x86。
$ TOOLCHAIN / mipsel-linux-android / lib / for MIPS toolchain
重要说明:GNU libstdc ++在GPLv3下获得了链接异常许可。有关详细信息,请参阅以下URL:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01s02.html
如果您无法满足其要求,即无法重新分发共享库,请不要在项目中使用它。
GNU libstdc ++的共享版本未被称为libstdc ++。因为这会在运行时与系统自己的最小C ++运行时冲突,即/system/lib/libstdc++.so。这将强制GNU ELF库的新名称。这对静态库来说不是问题。
答案 1 :(得分:0)
我有同样的错误。
要解决此问题,您必须在 Application.mk 文件中添加APP_STL := gnustl_static
。