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 网站上的内容一致:
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
知道如何解决这个问题吗?
谢谢。