在NDK版本(android-NDK-r8-windows)上编译protobuf-2.4.1代码

在NDK版本(android-NDK-r8-windows)上编译protobuf-2.4.1代码,android,android-ndk,android-ndk-r5,android-ndk-r7,Android,Android Ndk,Android Ndk R5,Android Ndk R7,大家好,我正在尝试在NDK版本(android-NDK-r8-windows)上编译protobuf-2.4.1代码 我已设定如下: 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)上编译protobuf-2.4.1代码

我已设定如下:

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
文件包含在D:/D\u 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:错误:字符串:没有这样的文件或目录
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:错误:向量:没有这样的文件或目录
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:错误:#错误“没有合适的线程库可用。”
文件包括在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:错误:命名空间“std”中的“string”未命名类型
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:错误:在“&”标记之前应该有非限定id
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:错误:预期为“&”标记之前的“')

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这来自NDK文档:

C++STL支持:

独立工具链还附带了GNU LIbSTDC++ +库的副本,它提供了C++标准模板库的实现。但是,要使用它,您需要链接到适当的库:

使用-lstdc++链接静态库版本。这确保了所有必需的C++ STL代码被包含到最终的二进制文件中。如果您只生成一个共享库或可执行文件,这是理想的。 这是推荐的方法

  • 使用-lgnustl_shared链接共享库版本。如果您有多个相关的共享库或可执行文件需要在运行时在同一地址空间中运行,则需要执行此操作(某些全局变量需要唯一定义,如果您将静态libstdc++链接到每个可执行文件,则无法执行此操作)

    如果使用此选项,则需要确保libgnustl_shared.so也复制到设备中,以便正确加载代码。该文件位于:

$TOOLCHAIN/arm-linux androideabi/lib/用于arm工具链

$TOOLCHAIN/i686 android linux/lib/用于x86操作系统

$TOOLCHAIN/mipsel linux android/lib/用于MIPS TOOLCHAIN

重要提示:GNU libstdc++在GPLv3下获得许可,但有一个链接例外。有关详细信息,请参阅以下URL:

      http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01s02.html
如果您不能遵守其要求,即无法重新分发共享库,请不要在项目中使用它


< GNU LIGBSTDC++的共享版本不被称为LIbSTDc++的原因,所以这是因为运行时会与系统自身的最小C++运行时冲突,即/St/Lab/LiBSTDc++。这将强制GNU ELF库使用新名称。这对于静态库来说不是问题。

这来自NDK文档:

C++STL支持:

独立工具链还附带了GNU LIbSTDC++ +库的副本,它提供了C++标准模板库的实现。但是,要使用它,您需要链接到适当的库:

使用-lstdc++链接静态库版本。这确保了所有必需的C++ STL代码被包含到最终的二进制文件中。如果您只生成一个共享库或可执行文件,这是理想的。 这是推荐的方法

  • 使用-lgnustl_shared链接共享库版本。如果您有多个相关的共享库或可执行文件需要在运行时在同一地址空间中运行,则需要执行此操作(某些全局变量需要唯一定义,如果您将静态libstdc++链接到每个可执行文件,则无法执行此操作)

    如果使用此选项,则需要确保libgnustl_shared.so也复制到设备中,以便正确加载代码。该文件位于:

$TOOLCHAIN/arm-linux androideabi/lib/用于arm工具链

$TOOLCHAIN/i686 android linux/lib/用于x86操作系统

$TOOLCHAIN/mipsel linux android/lib/用于MIPS TOOLCHAIN

重要提示:GNU libstdc++在GPLv3下获得许可,但有一个链接例外。有关详细信息,请参阅以下URL:

      http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01s02.html
如果您不能遵守其要求,即无法重新分发共享库,请不要在项目中使用它

< GNU LIGBSTDC++的共享版本不被称为LIbSTDc++的原因,所以这是因为运行时会与系统自身的最小C++运行时冲突,即/St/Lab/LiBSTDc++。这将强制GNU ELF库使用新名称。这对于静态库来说不是问题。

我也有同样的错误

要解决此问题,必须在Application.mk文件中包含
APP\u STL:=gnustl\u static

我也有同样的错误


要解决这个问题,你必须在你的Application.mk文件中有
APP\u STL:=gnustl\u static

在我的例子中,它已经存在了,但是仍然没有任何规则可以让target`jni/src/google/protobuf/stubs/common.cc给出任何建议!在我的例子中,它已经存在了,但仍然没有规则将target`jni/src/google/protobuf/stubs/common.cc作为任何建议