Go import work with cgo not with gccgo

I have a file logging.go that imports:

import (


The go-logging package is installed by calling
% echo $GOPATH /opt/gopath % echo $GOROOT /opt/go % go get github.com/op/go-logging

The program would build with
% go build logging.go

but fails for
% gccgo -c logging.go logging.go:26:26: error: import file 'github.com/op/go-logging' not found "github.com/op/go-logging" ^

I then used strace to track
% strace -f -o aa /usr/bin/gccgo -B /opt/gopath/src -fgo-pkgpath=<my_file_path> logging.go

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 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

How could I resolve the issue, assuming that only gccgo is available to me as the compiler?
Is there any way to build a go-logging.gox or go-logging.o manually, using gccgo?


That’s not the expected way to build code with gccgo, try instead.

go build -complete=gccgo

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.