kidoman / embd

Embedded Programming Framework in Go
http://embd.kidoman.io
MIT License
1.28k stars 156 forks source link

Can't build on windows. #62

Closed lukasmalkmus closed 7 years ago

lukasmalkmus commented 8 years ago

OS: Windows 10 Prof. 64 Go Version: 1.6

I tried to build a small sample program. It is designed for my Raspberry Pi. However, I failed very early when building was not possible. I face these errors when running go build:

vendor\github.com\kidoman\embd\host\generic\i2cbus.go:72: undefined: syscall.SYS_IOCTL
vendor\github.com\kidoman\embd\host\generic\i2cbus.go:72: not enough arguments in call to syscall.Syscall

They only appear if I import the Raspberry Pi Drivers. Building without the rpi package is possible, but won't work obvisiously.

wedgen commented 7 years ago

Same Issue

danesparza commented 7 years ago

Set the appropriate environment variables before building.

Example: export GOOS=linux and export GOARCH=arm

Then do a go install ./... and look under your go/bin directory. Remember that you're looking for a binary for another platform now -- it won't have an .exe extension. SCP the binary you find to your Raspberry Pi and you should be good to go.

lukasmalkmus commented 7 years ago

Oh wow, this issue is old. This was in my early go days where I wasn't familiar with the go tooling. Reading my own issue a year later makes me feel a little bit embarrassed. Anyway, thanks for the reply. Might be useful many new go newbies :)

danesparza commented 7 years ago

No worries. I remember being blown away by setting some environment variables and compiling for a different platform too. :smile:

wedgen commented 7 years ago

What about cross platform compiling? The OS its going on is Linux and the Arch is arm but wanted to build on windows. Is that possible?

danesparza commented 7 years ago

Absolutely. That's exactly what I do. I prefer to use the git 'bash' commandline window, but the concept is the same on windows: Set your GOOS and GOARCH environment variables and then run go install ./...