pebbe / zmq4

A Go interface to ZeroMQ version 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:10:4: undefined: State

hktalent opened this issue · comments

commented

code
$ cat chat.go

package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"

	"github.com/zeromq/gyre"
)

var (
	input = make(chan string)
	name  = flag.String("name", "Gyreman", "Your name or nick name in the chat session")
)

func chat() {
	node, err := gyre.New()
	if err != nil {
		log.Fatalln(err)
	}
	defer node.Stop()

	err = node.Start()
	if err != nil {
		log.Fatalln(err)
	}
	node.Join("CHAT")

	for {
		select {
		case e := <-node.Events():
			switch e.Type() {
			case gyre.EventShout:
				fmt.Printf("%c[2K\r%s%s> ", 27, string(e.Msg()), *name)
			}
		case msg := <-input:
			node.Shout("CHAT", []byte(msg))
		}
	}
}

func main() {
	flag.Parse()

	go chat()

	fmt.Printf("%s> ", *name)

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		input <- fmt.Sprintf("%s: %s\n", *name, scanner.Text())
		fmt.Printf("%s> ", *name)
	}
	if err := scanner.Err(); err != nil {
		log.Fatalln("reading standard input:", err)
	}
}
GOOS=linux GOARCH=amd64 go build -o linux_amd64  chat.go

error

# github.com/pebbe/zmq4
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:10:4: undefined: State
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:11:9: undefined: State
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:21:16: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:23:12: undefined: Poller
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:61:34: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:61:49: undefined: State
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/reactor.go:68:37: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/utils.go:17:12: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/utils.go:24:12: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/utils.go:28:12: undefined: Socket
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.8/utils.go:28:12: too many errors

$ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o linux_amd64 chat.go

# runtime/cgo
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:73:13: note: did you mean 'setreuid'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here

$ brew install FiloSottile/musl-cross/musl-cross
$ CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o linux_amd64 chat.go


# github.com/pebbe/zmq4
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x004.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_strerror':
/tmp/go-build/cgo-gcc-prolog:53: undefined reference to `zmq_strerror'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_bind':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:26: undefined reference to `zmq_bind'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_close':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:31: undefined reference to `zmq_close'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_connect':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:36: undefined reference to `zmq_connect'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_ctx_get':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:41: undefined reference to `zmq_ctx_get'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_ctx_new':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:46: undefined reference to `zmq_ctx_new'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_ctx_set':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:51: undefined reference to `zmq_ctx_set'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_ctx_term':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:56: undefined reference to `zmq_ctx_term'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_curve_keypair':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:61: undefined reference to `zmq_curve_keypair'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_curve_public':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:66: undefined reference to `zmq_curve_public'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_disconnect':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:71: undefined reference to `zmq_disconnect'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_getsockopt':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:76: undefined reference to `zmq_getsockopt'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_msg_gets':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:81: undefined reference to `zmq_msg_gets'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_msg_recv':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:86: undefined reference to `zmq_msg_recv'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_poll':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:91: undefined reference to `zmq_poll'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_proxy':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:96: undefined reference to `zmq_proxy'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_proxy_steerable':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:101: undefined reference to `zmq_proxy_steerable'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_send':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:106: undefined reference to `zmq_send'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_setsockopt':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:111: undefined reference to `zmq_setsockopt'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_socket':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:116: undefined reference to `zmq_socket'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_socket_monitor':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:121: undefined reference to `zmq_socket_monitor'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x009.o: in function `zmq4_unbind':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_unix.go:126: undefined reference to `zmq_unbind'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `zmq4_get_event40':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/zmq4.go:50: undefined reference to `zmq_msg_data'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `zmq4_get_event41':
../../../go/pkg/mod/github.com/pebbe/zmq4@v1.2.9/zmq4.go:57: undefined reference to `zmq_msg_data'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_has':
/tmp/go-build/cgo-gcc-prolog:838: undefined reference to `zmq_has'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_msg_close':
/tmp/go-build/cgo-gcc-prolog:857: undefined reference to `zmq_msg_close'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_msg_data':
/tmp/go-build/cgo-gcc-prolog:875: undefined reference to `zmq_msg_data'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_msg_init':
/tmp/go-build/cgo-gcc-prolog:894: undefined reference to `zmq_msg_init'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_z85_decode':
/tmp/go-build/cgo-gcc-prolog:927: undefined reference to `zmq_z85_decode'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_z85_encode':
/tmp/go-build/cgo-gcc-prolog:947: undefined reference to `zmq_z85_encode'
/usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/../lib/gcc/x86_64-linux-musl/9.2.0/../../../../x86_64-linux-musl/bin/ld: $WORK/b057/_x010.o: in function `_cgo_623c834d1dc5_Cfunc_zmq_version':
/tmp/go-build/cgo-gcc-prolog:911: undefined reference to `zmq_version'
collect2: error: ld returned 1 exit status

I'm getting the same issue. Did you find a way to fix it?

Seems like cross compiling for arm64 from an amd64 pc causes this issue.

commented

Cross platform cross compilation is a beautiful lie. Let's give it up

Ran into this issue on WSL2 when compiling the go code. The solution was to install gcc which wasn't installed yet and the code is just silently NOT being compiled. After installing gcc everything compiled fine.