Go/gccgo バージョン: 6.3.0
でプログラムを構築していgo build -compiler gccgo -x <args> <args> program.go
ます。ビルドプロセスが失敗する
% /usr/bin/gccgo -c -g -fgo-pkgpath=<file_path>/common/flogging -fgo-relative-import-path=<file_path>/common/flogging -o <dest_path>/common/flogging/)obj/_go_.o ./logging.go (some program specific args omitted)
% <file_path>/common/flogging
common/flogging/logging.go:26:26: error: import file 'github.com/op/go-
logging' not found
"github.com/op/go-logging"
^
logging.go
輸入品
import (
"io"
"os"
"regexp"
"strings"
"sync"
"github.com/op/go-logging"
)
logging.go
でスタンドアロンをコンパイルするとgo build
、正常にコンパイルされます。
[root@eef079aa0103 flogging]# go build logging.go
[root@eef079aa0103 flogging]# go build -compiler gccgo logging.go
コマンドをスタンドアロンで実行する/usr/bin/gccgo
と、エラーが持続します。
[root@eef079aa0103 flogging]# /usr/bin/gccgo <args> logging.go (args same with above)
logging.go:26:26: error: import file 'github.com/op/go-logging' not found
"github.com/op/go-logging"
^
昔strace
は追跡してた
% strace -f -o aa /usr/bin/gccgo <args> logging.go (args same with above)
そしてそれを知った
open("/opt/gopath/src/github.com/op/go-logging", O_RDONLY) = 10
open("/opt/gopath/src/github.com/op/go-logging.gox", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/gopath/src/github.com/op/libgo-logging.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/gopath/src/github.com/op/libgo-logging.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/gopath/src/github.com/op/go-logging.o", O_RDONLY) = -1 ENOENT (No such file or directory)
コンパイラはgo-logging
$GOPATH でパッケージを見つけることができますが、.gox
.so
.a
または.o
ファイルで何も表示されないために失敗します。
これは、Go Web サイトの内容と一致します。
When you import the package FILE with gccgo, it will look for the import data in the following files, and use the first one that it finds.
FILE.gox FILE.o libFILE.so libFILE.a
The gccgo compiler will look in the current directory for import files
どうすれば問題を解決できますか?
ありがとう。