Compiling a subset of Boost Libraries for Android NDK

I needed one of the accelerator libraries for my Android application, so I managed to build most of them. But when I try to compile the file system component, I get the 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 due to the fact that the Android NDK gcc does not have a part related to statvfs.h .

What interests me is whether the file system component is necessary for boost-spirit? Of course, if you know how to solve this error, it will be perfect.

+4
source share
1 answer

Solving your compilation error

I have not tried this with the Boost file system, but it will probably work:

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

If Boost Spirit needs a Boost file system

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

Why android does not have statvfs?

According to the manpage statvfs for POSIX, but Linux (and Android is based on Linux) does not obey it. The following quotes are used:

Some systems only have <sys/vfs.h> , other systems also have <sys/statfs.h> , where the former includes the latter. So the first one seems to be the best choice.


Solaris, Irix, and POSIX have a statvfs (2) system call that returns a statvfs structure (defined in <sys/statvfs.h> ) containing unsigned long f_fsid. Linux, SunOS, HP-UX, 4.4BSD have a statfs () system call that returns struct statfs (defined in <sys/vfs.h> ) containing fsid_t f_fsid, where fsid_t is defined as struct {int val 2 ; }. The same is true for FreeBSD, except that it uses the include <sys/mount.h> .

+3
source

Source: https://habr.com/ru/post/1383140/


All Articles