在cygwin上为android编译boost时无法识别的命令行选项

Tae*_*hin 5 c++ boost cygwin

我试图在以下文章的帮助下编译cygwin上的boost

但当我发表以下声明时

bjam --without-python --without-serialization toolset=gcc-android4.4.3 link=static runtime-link=static target-os=linux --stagedir=android
Run Code Online (Sandbox Code Playgroud)

它开始编译但由于以下错误而失败:

cc1plus.exe: error: unrecognized command line option "-mthreads"
Run Code Online (Sandbox Code Playgroud)

我正在使用最新的cygwin并提升1.48.0

如果有人能给我一个提示来消除这个错误,我将不胜感激.

更新:

我找到了解决方案 Boost假设cygwin有MingW gcc编译器,所以它在配置文件"gcc.jam"中添加了特殊选项.一旦我删除了选项,它运行正常.

CAM*_*BAP 1

短的

传递target-os=androidb2

解释

我在 Boost 1.59 中遇到了同样的问题

根据boost/tools/build/src/tools/gcc.jam第1024行

rule setup-threading ( targets * : sources * : properties * )
{
    local threading = [ feature.get-values threading : $(properties) ] ;
    if $(threading) = multi
    {
        local target = [ feature.get-values target-os : $(properties) ] ;
        local option ;
        local libs ;

        switch $(target)
        {
            case android : # No threading options, everything is in already.
            case windows : option = -mthreads ;
            case cygwin  : option = -mthreads ;
            case solaris : option = -pthreads ; libs = rt ;
            case beos    : # No threading options.
            case haiku   : option = ;
            case *bsd    : option = -pthread ;  # There is no -lrt on BSD.
            case sgi     : # gcc on IRIX does not support multi-threading.
            case darwin  : # No threading options.
            case *       : option = -pthread ; libs = rt ;
        }

        if $(option)
        {
            OPTIONS on $(targets) += $(option) ;
        }
        if $(libs)
        {
            FINDLIBS-SA on $(targets) += $(libs) ;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的-mthreads取决于target-os参数