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)
编译器能够在我的$ GOPATH中找到go-logging
包,但由于.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
我知道如何解决这个问题?
感谢。