使用 Android NDK 编译 PugiXML

Compiling PugiXML with Android NDK

我正在尝试使用 Android NDK 编译 PugiXML 库;它在网站上说这是可能的,但下载不包含 android makefile 并且我之前没有使用过 NDK(文档没有帮助!)

我目前遇到错误:

/pugiconfig.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

我最初收到一个错误,因为 NDK 找不到 #include <iterator>,我不确定我是否正确解决了这个问题。我尝试遵循 this Whosebug Q/A 并以上面显示的错误结束。

我现在的 Android.mk 是这样的:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := webface
LOCAL_CPP_EXTENSION := .hpp .cpp
LOCAL_SRC_FILES := ../pugiconfig.hpp ../pugixml.hpp ../pugixml.cpp

include $(BUILD_SHARED_LIBRARY)

我现在的 Application.mk 看起来像这样:

APP_ABI := all
APP_STL := stlport_shared

我建议从 LOCAL_SRC_FILES 中删除 pugixml.cpp 以外的所有内容。

此外,请注意,如果您遇到问题,可以使用 PUGIXML_NO_STL 进行编译(通过将 -DPUGIXML_NO_STL 添加到 CXXFLAGS)。