Closed volker-raschek closed 5 years ago
Hi @volker-raschek! Sorry, for delayed response.
You should remember, that since DHT library partially written in C (and your native system has no ARM7 architecture), and you employ "cross compilation techniques", so you should have on your system special cross c-compiler installed. The name of c-compiler for Debian/Ubuntu system will be arm-linux-gnueabi-gcc
, for Arch Linux arm-linux-gnueabihf-gcc
.
So, once you have this c-compiler, you must modify your compilation call accordingly:
CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7|6 go build
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7|6 go build
Note: you should select ARM version 6 or 7. Regular Raspberry PI ordinary has 6.
I have one on my Arch Linux notebook where i'm doing all the development (and cross compilation works good), and as I remember arch ecosystem has this compiler only in AUR repository, so you should install it from here: https://aur.archlinux.org/packages/arm-linux-gnueabihf-gcc/
I think the hardest part here is installing a с-compiler, so try and let me know if you still need help.
I try to read out the data of my DHT11 sensor using the example. My Golang code looks like this:
I downloaded the lib via
go get -u github.com/d2r2/go-dht
.Thereby compile the binary on my Arch Linux system. Therefore I give the ARM, OS and ARCH variables so that the binary is executable on the Pi. When compelling I get the following error:
Does anyone have any idea what I'm doing wrong?