I am trying to install boost 1.5 into android according to this.
When I compile, I get an error. Here is a fragment of the compilation error:
gcc.compile.c++ bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link- static/threading-multi/pthread/thread.o
<command-line>: warning: "BOOST_FILESYSTEM_VERSION" redefined
<command-line>: warning: this is the location of the previous definition
In file included from ./boost/thread/thread.hpp:17,
from libs/thread/src/pthread/thread.cpp:11:
./boost/thread/pthread/thread_data.hpp: In member function 'void boost::thread_attributes::set_stack_size(size_t)':
./boost/thread/pthread/thread_data.hpp:42: error: 'PAGE_SIZE' was not declared in this scope
"../../toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic --sysroot=../../platforms/android-9/arch-arm -mthumb -Os -fno-strict-aliasing -O2 -DNDEBUG -g -lstdc++ -I../../sources/cxx-stl/gnu-libstdc++/include -I../../sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -D__GLIBC__ -DBOOST_NO_INTRINSIC_WCHAR_T -DBOOST_FILESYSTEM_VERSION=2 -pthread -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link-static/threading-multi/pthread/thread.o" "libs/thread/src/pthread/thread.cpp"
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link-static/threading-multi/pthread/thread.o...
I found this error which I didn’t understand …
./boost/thread/pthread/thread_data.hpp:42: error: 'PAGE_SIZE' was not declared in this scope. It says PAGE_SIZE was not declared, but I have no idea what that means. And when I tried to look at that particular location in the code I did not find PAGE_SIZE.
Compilation errors like this are typically resolved by looking first at the preprocessed output. Try replacing
-cwith-Eand changing thefoo.otofoo.pp(or something else) and review thefoo.ppfile for errors (search forset_stack_size).This is the relevant code:
getpagesize()expands to something which referencesPAGE_SIZE. I’m pretty suresysconfis the Right Way ™ to get the page size these days, but the boost maintainers might’ve had a good reason for usinggetpagesize(). Regardless, you can dodge this specific error with a-DPAGE_SIZE=2048compiler argument, or whatever your target’s page size is. Either that, or patch the source to usesysconf(_SC_PAGESIZE)instead.