Building Golang applications for RDK
We want to cross-compile a Golang application (with a libpcap cgo dependency) for a Raspberry Pi running the RDK-B stack. We exported the SDK while building the RDK-B image for the target and attempted to use that to build our Golang app. However, we found that cgo doesn’t identify the environment variables exported by the SDK (stdlib.h wasn’t found!) and we had to provide the toolchain configuration manually like so:
CGO_CFLAGS=”–sysroot /opt/rdk/2.0/sysroots/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/ -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -fno-omit-frame-pointer -fno-optimize-sibling-calls” CGO_LDFLAGS=”–sysroot /opt/rdk/2.0/sysroots/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/”
Further, even after resolving all the dependencies manually, we found that the target application links to the interpreter /lib/ld-linux.so.3, instead of /lib/ld-linux-armhf.so.3 and the application doesn’t run on the Raspberry Pi unless the interpreter is specified.
However, we found that when we built the application with the Raspberry Pi toolchain (GCC 4.9.3), the compilation was smooth and the application runs fine on the RDK-B Raspberry Pi reference platform. In fact, we only had to use the command,
env CC=arm-linux-gnueabihf-gcc LD=arm-linux-gnueabihf-ld GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 go build
- Are we using the SDK incorrectly or have we built/exported it incorrectly? The problem we’re facing seems to be due to a misconfigured SDK.
Is there any difference between the RPI toolchain and the RDK-B SDK one? Can we continue to use the Raspberry Pi toolchain instead of the RDK one?
- This topic has 0 replies, 1 voice, and was last updated 7 months, 1 week ago by .