keltia / dmarc-cat

Small utility to decode the report sent by various email providers following the DMARC spec
Other
62 stars 13 forks source link

Cannot compile on Centos 7 #3

Closed jfoucry closed 4 years ago

jfoucry commented 5 years ago

After installating gpgme and gpgme-devel, dependencies the go get github.com/keltia/dmarc-cat command failed:

# get github.com/keltia/dmarc-cat  
# github.com/proglottis/gpgme
go/src/github.com/proglottis/gpgme/data.go:184:12: could not determine kind of name for C.gogpgme_data_seek
go/src/github.com/proglottis/gpgme/data.go:53:53: could not determine kind of name for C.gpgme_off_t
cgo: 
gcc errors for preamble:
In file included from go/src/github.com/proglottis/gpgme/data.go:6:0:
./go_gpgme.h:15:1: error: unknown type name 'gpgme_off_t'
 extern gpgme_off_t gogpgme_data_seek(gpgme_data_t dh, gpgme_off_t offset, int whence);
 ^
./go_gpgme.h:15:55: error: unknown type name 'gpgme_off_t'
 extern gpgme_off_t gogpgme_data_seek(gpgme_data_t dh, gpgme_off_t offset, int whence);
# uname -rms                  
Linux 3.10.0-957.27.2.el7.x86_64 x86_64
# go version
go version go1.11.5 linux/amd64
# yum gpgme info
Installed Packages
Name        : gpgme
Arch        : x86_64
Version     : 1.3.2
Release     : 5.el7
Size        : 535 k
Repo        : installed
From repo   : anaconda
Summary     : GnuPG Made Easy - high level crypto API
URL         : http://www.gnupg.org/related_software/gpgme/
License     : LGPLv2+
Description : GnuPG Made Easy (GPGME) is a library designed to make access to
            : GnuPG easier for applications.  It provides a high-level crypto
            : API for encryption, decryption, signing, signature verification
            : and key management.
# yum gpgme-devel info
Name        : gpgme-devel
Arch        : x86_64
Version     : 1.3.2
Release     : 5.el7
Size        : 160 k
Repo        : installed
From repo   : base
Summary     : Development headers and libraries for gpgme
URL         : http://www.gnupg.org/related_software/gpgme/
License     : LGPLv2+
Description : Development headers and libraries for gpgme
keltia commented 5 years ago

We seem to be lacking a few environment variables for the cgo build:

CGO_CFLAGS="-I/usr/local/include" CGO_LDFLAGS="-L/usr/local/lib" go build -x -work -gccgoflags="-I/usr/local/include" -ldflags="-L/usr/local/lib" -v .

Not sure if both variables & -*flags are needed but this should fix the build if you put the right paths.

jfoucry commented 5 years ago

Your command seems to work:

cd $WORK/b055
TERM='dumb' gcc -I /usr/lib/golang/src/os/user -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x001.o -c _cgo_export.c
cd $WORK/b066
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x001.o -c _cgo_export.c
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x002.o -c cgo_linux.cgo2.c
cd $WORK/b055
TERM='dumb' gcc -I /usr/lib/golang/src/os/user -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x002.o -c cgo_lookup_unix.cgo2.c
cd $WORK/b066
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x003.o -c cgo_resnew.cgo2.c
cd $WORK/b055
TERM='dumb' gcc -I /usr/lib/golang/src/os/user -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x003.o -c getgrouplist_unix.cgo2.c
cd $WORK/b066
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x004.o -c cgo_socknew.cgo2.c
cd $WORK/b055
TERM='dumb' gcc -I /usr/lib/golang/src/os/user -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x004.o -c listgroups_unix.cgo2.c
cd $WORK/b066
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_x005.o -c cgo_unix.cgo2.c
cd $WORK/b055
TERM='dumb' gcc -I /usr/lib/golang/src/os/user -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_cgo_main.o -c _cgo_main.c
cd /usr/lib/golang/src/os/user
TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b055=/tmp/go-build -gno-record-gcc-switches -o $WORK/b055/_cgo_.o $WORK/b055/_cgo_main.o $WORK/b055/_x001.o $WORK/b055/_x002.o $WORK/b055/_x003.o $WORK/b055/_x004.o -L/usr/local/lib
cd $WORK/b066
TERM='dumb' gcc -I /usr/lib/golang/src/net -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -I ./ -I/usr//local/include -o ./_cgo_main.o -c _cgo_main.c
cd /usr/lib/golang/src/os/user
TERM='dumb' /usr/lib/golang/pkg/tool/linux_amd64/cgo -dynpackage user -dynimport $WORK/b055/_cgo_.o -dynout $WORK/b055/_cgo_import.go
cat >$WORK/b055/importcfg << 'EOF' # internal
# import config
packagefile fmt=/usr/lib/golang/pkg/linux_amd64/fmt.a
packagefile strconv=/usr/lib/golang/pkg/linux_amd64/strconv.a
packagefile strings=/usr/lib/golang/pkg/linux_amd64/strings.a
packagefile sync=/usr/lib/golang/pkg/linux_amd64/sync.a
packagefile syscall=/usr/lib/golang/pkg/linux_amd64/syscall.a
packagefile runtime/cgo=$WORK/b056/_pkg_.a
EOF
/usr/lib/golang/pkg/tool/linux_amd64/compile -o $WORK/b055/_pkg_.a -trimpath $WORK/b055 -p os/user -std -buildid goILWRZBEIGHvT1xobsC/goILWRZBEIGHvT1xobsC -goversion go1.11.5 -D "" -importcfg $WORK/b055/importcfg -pack -c=4 ./lookup.go ./user.go $WORK/b055/_cgo_gotypes.go $WORK/b055/cgo_lookup_unix.cgo1.go $WORK/b055/getgrouplist_unix.cgo1.go $WORK/b055/listgroups_unix.cgo1.go $WORK/b055/_cgo_import.go
cd /usr/lib/golang/src/net
TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b066=/tmp/go-build -gno-record-gcc-switches -o $WORK/b066/_cgo_.o $WORK/b066/_cgo_main.o $WORK/b066/_x001.o $WORK/b066/_x002.o $WORK/b066/_x003.o $WORK/b066/_x004.o $WORK/b066/_x005.o -L/usr/local/lib
TERM='dumb' /usr/lib/golang/pkg/tool/linux_amd64/cgo -dynpackage net -dynimport $WORK/b066/_cgo_.o -dynout $WORK/b066/_cgo_import.go
cat >$WORK/b066/importcfg << 'EOF' # internal
# import config
packagefile context=/usr/lib/golang/pkg/linux_amd64/context.a
packagefile errors=/usr/lib/golang/pkg/linux_amd64/errors.a
packagefile golang_org/x/net/dns/dnsmessage=/home/jfoucry/.cache/go-build/7e/7e8f0a5a4effcac4c46f81368a6c20e90d89fe4d84b27aad3a4cb1596ee7402b-d
packagefile internal/nettrace=/usr/lib/golang/pkg/linux_amd64/internal/nettrace.a
packagefile internal/poll=/usr/lib/golang/pkg/linux_amd64/internal/poll.a
packagefile internal/singleflight=/usr/lib/golang/pkg/linux_amd64/internal/singleflight.a
packagefile io=/usr/lib/golang/pkg/linux_amd64/io.a
packagefile math/rand=/usr/lib/golang/pkg/linux_amd64/math/rand.a
packagefile os=/usr/lib/golang/pkg/linux_amd64/os.a
packagefile runtime=/usr/lib/golang/pkg/linux_amd64/runtime.a
packagefile sort=/usr/lib/golang/pkg/linux_amd64/sort.a
packagefile sync=/usr/lib/golang/pkg/linux_amd64/sync.a
packagefile sync/atomic=/usr/lib/golang/pkg/linux_amd64/sync/atomic.a
packagefile syscall=/usr/lib/golang/pkg/linux_amd64/syscall.a
packagefile time=/usr/lib/golang/pkg/linux_amd64/time.a
packagefile runtime/cgo=$WORK/b056/_pkg_.a
EOF
/usr/lib/golang/pkg/tool/linux_amd64/compile -o $WORK/b066/_pkg_.a -trimpath $WORK/b066 -p net -std -buildid TpdBTTtBMJHv-kfXgnkE/TpdBTTtBMJHv-kfXgnkE -goversion go1.11.5 -D "" -importcfg $WORK/b066/importcfg -pack -c=4 ./addrselect.go ./conf.go ./dial.go ./dnsclient.go ./dnsclient_unix.go ./dnsconfig_unix.go ./error_posix.go ./error_unix.go ./fd_unix.go ./file.go ./file_unix.go ./hook.go ./hook_unix.go ./hosts.go ./interface.go ./interface_linux.go ./ip.go ./iprawsock.go ./iprawsock_posix.go ./ipsock.go ./ipsock_posix.go ./lookup.go ./lookup_unix.go ./mac.go ./net.go ./nss.go ./parse.go ./pipe.go ./port.go ./port_unix.go ./rawconn.go ./sendfile_linux.go ./sock_cloexec.go ./sock_linux.go ./sock_posix.go ./sockaddr_posix.go ./sockopt_linux.go ./sockopt_posix.go ./sockoptip_linux.go ./sockoptip_posix.go ./splice_linux.go ./tcpsock.go ./tcpsock_posix.go ./tcpsockopt_posix.go ./tcpsockopt_unix.go ./udpsock.go ./udpsock_posix.go ./unixsock.go ./unixsock_posix.go ./writev_unix.go $WORK/b066/_cgo_gotypes.go $WORK/b066/cgo_linux.cgo1.go $WORK/b066/cgo_resnew.cgo1.go $WORK/b066/cgo_socknew.cgo1.go $WORK/b066/cgo_unix.cgo1.go $WORK/b066/_cgo_import.go
cd /usr/lib/golang/src/os/user
/usr/lib/golang/pkg/tool/linux_amd64/pack r $WORK/b055/_pkg_.a $WORK/b055/_x001.o $WORK/b055/_x002.o $WORK/b055/_x003.o $WORK/b055/_x004.o # internal
/usr/lib/golang/pkg/tool/linux_amd64/buildid -w $WORK/b055/_pkg_.a # internal
cp $WORK/b055/_pkg_.a /home/jfoucry/.cache/go-build/4d/4dc073c0966b228b260274daa3be9c8efc1c387c505b5a3da8c9a950d137422b-d # internal
cd /usr/lib/golang/src/net
/usr/lib/golang/pkg/tool/linux_amd64/pack r $WORK/b066/_pkg_.a $WORK/b066/_x001.o $WORK/b066/_x002.o $WORK/b066/_x003.o $WORK/b066/_x004.o $WORK/b066/_x005.o # internal
/usr/lib/golang/pkg/tool/linux_amd64/buildid -w $WORK/b066/_pkg_.a # internal
cp $WORK/b066/_pkg_.a /home/jfoucry/.cache/go-build/e2/e24cd2880bf6d8be95a542dca9f2f9fcf00e619c933fcaf1f2d9fe822a0c91d9-d # internal

But if I use the go get github.com/keltia/dmarc-cat command next, it failed again with the same error.

NB: I am more than stupid with go

jfoucry commented 5 years ago

Update: Your command line works on FreeBSD. Il will recheck on centos.

keltia commented 4 years ago

Thanks, I'll document that too.