Go/gccgo version: 6.3.0
I am building a program with go build -compiler gccgo -x <args> <args> program.go
. Build process fails with
% /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
imports
import (
"io"
"os"
"regexp"
"strings"
"sync"
"github.com/op/go-logging"
)
If I compile logging.go
standalone with go build
, it compiles fine:
[root@eef079aa0103 flogging]# go build logging.go
[root@eef079aa0103 flogging]# go build -compiler gccgo logging.go
If I run the /usr/bin/gccgo
command standalone, the error persists.
[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"
^
I used strace
to track
% strace -f -o aa /usr/bin/gccgo <args> logging.go (args same with above)
and found out that
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)
the compiler is able to find go-logging
package in my $GOPATH, but it fails for not seeing anything with .gox
.so
.a
or .o
file.
Which agrees with whats on the Go website:
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
Any idea how could I resolve the issue?
Thanks.