distributed / sers

Serial port access for the Go programming language.
MIT License
38 stars 7 forks source link

Does not compile for ARM devices: undefined: sers.Open #10

Closed biohazduck closed 1 year ago

biohazduck commented 1 year ago
$ GOOS=linux GOARCH=arm GOARM=7 go build -o=vaisala.bin .
# github.com/soypat/cereal
../../../go/pkg/mod/github.com/soypat/cereal@v0.0.0-20230618213158-ce082d3b2e3e/cereal.go:160:18: undefined: sers.Open
distributed commented 1 year ago

Hi again :)

The issues is that sers currently needs cgo in order to pull in some constants and structure definitions from C header files. Because your cross build is not using cgo by default, the file that contains sers.Open does not get built. Unfortunately I don't know how to make the error message clearer as I have no control over it.

You will need to build with cgo, e.g.

GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 CC=... go build

where you provide your cross C compiler. I tried on my machine with CC=arm-linux-gnueabi-gcc and it worked, but you will need to find out the correct name on your end.

As stated in the readme, I would like to provide a sers version that uses no cgo (like what is already done on Windows) but I haven't gotten to it in years. One of the worst aspects is that I'd like to have some kind of test suite and run it on all supported OSes, but I don't have it yet, so I reluctant to do changes and here we are :)

biohazduck commented 1 year ago

Thanks, was able to compile like that. Just had to run sudo apt install gcc-arm-linux-gnueabi beforehand :ok_hand: