2017-09-07 8 views
2

私はgoを使ってクロスプラットフォームのネイティブライブラリを作成しようとしていて、gomobileのチュートリアルthisが見つかりました。しかし、私はそれを初期化しようとすると(たとえ私が下の例ではないがAndroid NDKのパスを与えても)、それはstdlib.hを見つけることができないので失敗するようです。gomobile initがstdlib.hを見つけることに失敗しました

私はコゴの周りでいくつかの調査を試みましたが、私に飛び出したものはありませんでした。生態系に精通した人が私に正しい方向を向けることを望んでいました。

$ gomobile init 
gomobile: go install -gcflags=-shared -ldflags=-shared -pkgdir=/Users/myusername/go/pkg/gomobile/pkg_android_arm std failed: exit status 2 
# runtime/cgo 
_cgo_export.c:2:10: fatal error: 'stdlib.h' file not found 

私の環境...(私は新鮮go1.9ダーウィン/ AMD64のインストールとOS Xエルキャピタンによ)

$ go env 
GOARCH="amd64" 
GOBIN="" 
GOEXE="" 
GOHOSTARCH="amd64" 
GOHOSTOS="darwin" 
GOOS="darwin" 
GOPATH="/Users/myusername/go" 
GORACE="" 
GOROOT="/usr/local/go" 
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" 
GCCGO="gccgo" 
CC="clang" 
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rx/l7pzlrld2mqczrfb36t536hh0000gp/T/go-build735124167=/tmp/go-build -gno-record-gcc-switches -fno-common" 
CXX="clang++" 
CGO_ENABLED="1" 
CGO_CFLAGS="-g -O2" 
CGO_CPPFLAGS="" 
CGO_CXXFLAGS="-g -O2" 
CGO_FFLAGS="-g -O2" 
CGO_LDFLAGS="-g -O2" 
PKG_CONFIG="pkg-config" 

EDIT:(失敗したのinitの詳細な出力を追加します)

 
$ gomobile init -v 

# Installing golang.org/x/mobile/gl. 

# Installing golang.org/x/mobile/app. 

# Installing golang.org/x/mobile/exp/app/debug. 

# Installing std for android/arm. 
runtime/internal/sys 
runtime/internal/atomic 
runtime 
sync/atomic 
unicode 
internal/race 
errors 
unicode/utf8 
math 
math/bits 
container/list 
container/ring 
crypto/subtle 
crypto/internal/cipherhw 
internal/nettrace 
runtime/cgo 
vendor/golang_org/x/crypto/poly1305 
sync 
encoding 
unicode/utf16 
image/color 
internal/cpu 
internal/syscall/windows 
internal/syscall/windows/registry 
image/color/palette 
internal/syscall/windows/sysdll 
io 
syscall 
internal/singleflight 
runtime/race 
# runtime/cgo 
_cgo_export.c:2:10: fatal error: 'stdlib.h' file not found 
vendor/golang_org/x/text/secure 
vendor/golang_org/x/text/unicode 
bytes 
strings 
hash 
crypto/cipher 
runtime/trace 
hash/crc32 
hash/adler32 
crypto/hmac 
hash/crc64 
hash/fnv 
vendor/golang_org/x/text/transform 
text/tabwriter 
bufio 
path 
html 
strconv 
math/rand 
math/cmplx 
time 
internal/syscall/unix 
reflect 
crypto/aes 
crypto 
crypto/rc4 
encoding/base64 
encoding/base32 
encoding/ascii85 
crypto/sha512 
crypto/md5 
crypto/sha1 
crypto/sha256 
image 
internal/poll 
image/internal/imageutil 
image/draw 
image/jpeg 
os 
os/signal 
fmt 
sort 
encoding/binary 
path/filepath 
compress/bzip2 
encoding/pem 
container/heap 
regexp/syntax 
runtime/debug 
crypto/des 
vendor/golang_org/x/crypto/chacha20poly1305/internal/chacha20 
vendor/golang_org/x/crypto/curve25519 
vendor/golang_org/x/crypto/chacha20poly1305 
io/ioutil 
compress/flate 
context 
archive/tar 
math/big 
compress/lzw 
encoding/hex 
debug/dwarf 
debug/gosym 
debug/plan9obj 
database/sql/driver 
encoding/csv 
encoding/gob 
encoding/json 
database/sql 
encoding/xml 
archive/zip 
compress/gzip 
compress/zlib 
debug/macho 
debug/elf 
debug/pe 
log 
vendor/golang_org/x/net/http2/hpack 
vendor/golang_org/x/text/unicode/bidi 
vendor/golang_org/x/text/unicode/norm 
net/url 
mime 
mime/quotedprintable 
net/http/internal 
flag 
crypto/dsa 
crypto/elliptic 
encoding/asn1 
crypto/rand 
go/token 
go/scanner 
crypto/rsa 
vendor/golang_org/x/text/secure/bidirule 
regexp 
text/template/parse 
go/ast 
go/constant 
os/exec 
text/scanner 
crypto/ecdsa 
crypto/x509/pkix 
image/gif 
image/png 
vendor/golang_org/x/net/idna 
index/suffixarray 
testing 
internal/trace 
runtime/pprof 
text/template 
net/internal/socktest 
os/user 
runtime/pprof/internal/profile 
testing/iotest 
testing/quick 
go/parser 
go/printer 
testing/internal/testdeps 
internal/testenv 
go/doc 
html/template 
go/types 
go/format 
go/build 
go/internal/gccgoimporter 
go/internal/gcimporter 
go/internal/srcimporter 
go/importer 
gomobile: go install -gcflags=-shared -ldflags=-shared -pkgdir=/Users/myusername/go/pkg/gomobile/pkg_android_arm -v std failed: exit status 2 
+0

xcodeコマンドラインツールをインストールしましたか? – JimB

+0

はい、それらのパスをリセットします(パスを変更していない、すでにデフォルトを使用している必要があります)。設定に問題がある場合は、それ以上のものでなければなりません。 – jm0

+0

種類の混乱...もし私が '' gmobileがそれを実行しようとすると、 '' install -gcflags = -shared -ldflags = -shared -pkgdir =/Users/myusername/go/pkg/gomobile/pkg_android_arm std' ? (これはまだinitが私のために壊れていることを意味します...) – jm0

答えて

0

問題はまだissue21802は、パッチを適用してもしてgo1.10 darwin/amd64に再現しました。

go install -gcflags=-shared -ldflags=-shared -pkgdir=/Users/myusername/go/pkg/gomobile/pkg_android_arm stdを単独で実行することはできますが、問題が実行時ENVの問題であると仮定すると、回避策があります。

この問題を解決するためのトリック:

1.Run go install -gcflags=-shared -ldflags=-shared -pkgdir=/Users/myusername/go/pkg/gomobile/pkg_android_arm std手動。 がインストールされていることを確認してくださいが正常にインストールされています。

2.テントサイレントinstallStd内側init.go

go/src/golang.org/x/mobile/cmd/gomobile/init.go (around Line 165-175) 
// Install standard libraries for cross compilers. 
start := time.Now() 
//if ndkRoot != "" { 
    // Ideally this would be -buildmode=c-shared. 
    // https://golang.org/issue/13234. 
    // androidArgs := []string{"-gcflags=-shared", "-ldflags=-shared"} 
    // for _, arch := range archs { 
     // env := androidEnv[arch] 
     // if err := installStd(env, androidArgs...); err != nil { 
      // return err 
     // } 
    // } 
//} 

3.Install回避策は再びgomobile: go install golang.org/x/mobile/cmd/gomobile

4.Run gomobile init再び。

関連する問題