「android」gomobile argument unused during compilation: '-stdlib=libc++'

【问题】

android基于go的NDK开发中配置gomobile参考官方WIKI:https://github.com/golang/go/wiki/Mobile,大致步骤:

1、下载gomobile:$ go get golang.org/x/mobile/cmd/gomobile

2、初始化 $ gomobile init
但是使用gomobile编译官方例子($ gomobile build -target=android golang.org/x/mobile/example/basic)

时提示错误:argument unused during compilation: '-stdlib=libc++'

版本:go 1.11,mac os10.13.1

【解决】

网上居然没搜到该问题,难道就我遇到了这个问题? 开始以为是clang,gcc引起的,更新了go版本,无效。

从字面上理解这个错误,是编译时带了-stdlib=libc++,但是却没有用到该参数???

libc++是针对clang编译器特别重写的C++标准库,libstdc++是gcc的,单独编译用gcc和clang编译cpp文件,无论是否带-stdlib=libc++,均正常。

在官方的github上不小心搜到了一样的问题,我去!花了这么多时间。

修改android的ndk中的build/tools/make_standalone_toolchain.py,去掉-stdlib=libc++,两个地方:

1、flags = '-target {} -stdlib=libc++'.format(target)改为flags = '-target {}'.format(target)

2、cxx_flags = flags + ' -stdlib=libc++'改为cxx_flags = flags

修改之后重新 $ gomobile init

posted on 2019-01-21 17:29  trako  阅读(512)  评论(0编辑  收藏  举报

导航