我的 Android 应用程序需要一个 boost 库,所以我设法编译了其中的大部分。但是当我尝试编译文件系统组件时,出现以下错误消息。
gcc.compile.c++ bin.v2/libs/filesystem/build/gcc-android4.4.3/release/link-static/runtime-link-static/threading-multi/v2/src/v2_operations.o
libs\filesystem\v2\src\v2_operations.cpp:62:30:
error: sys/statvfs.h: No such file or directory
我理解这是因为Android NDK的gcc没有statvfs.h
相关的部分。
我想知道的是,boost-spirit 是否需要文件系统组件?当然,如果您知道如何解决该错误,那就完美了。
最佳答案
解决编译错误
我还没有用 Boost Filesystem 尝试过这个,但它可能会起作用:
#ifndef ANDROID
#include <sys/statvfs.h>
#else
#include <sys/vfs.h>
#define statvfs statfs
#endif
如果 Boost Spirit 需要 Boost 文件系统
根据 boost manual它是一个只有标题的模块。 :)
为什么android没有statvfs?
根据其manpage , statvfs 是针对 POSIX 的,但是 Linux(Android 是基于 Linux 的)不服从它。以下引号适用:
Some systems only have
<sys/vfs.h>
, other systems also have<sys/statfs.h>
, where the former includes the latter. So it seems including the former is the best choice.
Solaris, Irix and POSIX have a system call statvfs(2) that returns a struct statvfs (defined in
<sys/statvfs.h>
) containing an unsigned long f_fsid. Linux, SunOS, HP-UX, 4.4BSD have a system call statfs() that returns a struct statfs (defined in<sys/vfs.h>
) containing a fsid_t f_fsid, where fsid_t is defined as struct { int val2; }. The same holds for FreeBSD, except that it uses the include file<sys/mount.h>
.
关于c++ - 为 Android NDK 编译 Boost 库的子集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8275203/