为 Android 构建 Boost 时出现错误 "cannot find -lrt"

Building Boost for Android with error "cannot find -lrt"

所以我正在尝试为 android 构建 boost 1.55,但我收到 linking Boost.System 和 Boost.Atomic 的错误,即 "error: cannot find -lrt".当然,android 没有 librt,因为它内置于 C 运行时中。所以,我正在尝试获得提升,这样它就不会 link 到 librt。我尝试删除源代码中的每个“-lrt”:

find . -type f | xargs -n1 -P 8 sed -i "s/-lrt//g"

但我仍然遇到同样的错误。我如何使 boost not link 反对 librt for android?

事实上,所有出现的 -lrt 与 sed 似乎对问题没有任何影响。
对我有用的(尽管在 boost 1.53.0 中)如下:

  • 编辑tools/build/v2/tools/gcc.jam
  • 在此代码部分注释libs = rt ;(顺便说一下,可能是您没有-pthread选项行):

        case * :
        {
            option = -pthread ;
            libs = rt ;   <--Comment this line
        }
    

注意:作为 initial/brute 强制解决方案,我会采取失败的命令并手动 运行 从中删除 -lrt