为 Android NDK 编译 Boost 库的子集

发布于 2024-12-18 00:15:15 字数 477 浏览 1 评论 0原文

我的 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 是否是必需的?当然,如果您知道如何解决该错误,那就完美了。

I needed one of boost libraries for my Android app so I managed to compile most of them. But when I am trying to compile filesystem component, I get following error message.

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

I understand that this is because Android NDK's gcc does not have the part related to statvfs.h.

What I am wondering, is if filesystem component is necessary for boost-spirit? Of course, if you know how to resolve that error, that would be perfect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山田美奈子 2024-12-25 00:15:15

解决你的编译错误

我还没有尝试过使用 Boost Filesystem,但它可能会起作用:

#ifndef ANDROID
  #include <sys/statvfs.h>
#else
  #include <sys/vfs.h>
  #define statvfs statfs
#endif

如果 Boost Spirit 需要 Boost Filesystem

根据 boost 手册 它是一个仅包含标题的模块。 :)

为什么 android 没有 statvfs?

根据其手册页,statvfs是POSIX,但 Linux(Android 是基于 Linux 的)不遵守它。以下引用适用:

有些系统只有,其他系统也有,前者包含后者。所以看来包含前者是最好的选择。

Solaris、Irix 和 POSIX 有一个系统调用 statvfs(2),它返回一个包含 unsigned long f_fsid 的 struct statvfs(在 中定义)。 Linux、SunOS、HP-UX、4.4BSD 有一个系统调用 statfs(),它返回一个包含 fsid_t f_fsid 的 struct statfs(在 中定义),其中定义了 fsid_t作为结构体{ int val2; }。 FreeBSD 也是如此,只不过它使用包含文件

Solving your compilation error

I haven't tried this with Boost Filesystem but it will probably work:

#ifndef ANDROID
  #include <sys/statvfs.h>
#else
  #include <sys/vfs.h>
  #define statvfs statfs
#endif

If Boost Spirit needs Boost Filesystem

According to boost manual it is a header-only module. :)

Why doesn’t android have statvfs?

According to its manpage, statvfs is for POSIX, but Linux (and Android is based on Linux) disobeys it. Following quotes applies:

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>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文