Go导入包:使用Go(-compiler gccgo)找到pkg,但未使用gccgo找到

Go导入包:使用Go(-compiler gccgo)找到pkg,但未使用gccgo找到,gcc,go,gccgo,Gcc,Go,Gccgo,Go/gccgo版本:6.3.0 我正在用go build-compiler gccgo-x 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

Go/gccgo版本:6.3.0

我正在用
go build-compiler gccgo-x 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"
                          ^
如果我使用
go build
独立编译
logging.go
,它编译得很好:

[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"  
                          ^
你知道我该如何解决这个问题吗


谢谢。

go env
并告诉我们您的设置。还可能需要运行
哪个go
哪个gccgo
gccgo
只是编译器,它不是
go
工具的替代品。如果您想查看如何调用编译器,请使用
-x
标志:
go build-x-compiler gccgo logging.go
@JimB您是对的。我最初的尝试是构建一个程序,其中已经给出了一个Makefile(内部还有一个“go build”命令)。构建失败,我使用“-x”标志将范围缩小到一个“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"  
                          ^
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