From 3f0fa81f18f2051d233e6d0ce64f6f26bc524756 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Sun, 13 Sep 2020 17:57:50 +0200 Subject: [PATCH] Update build for cross-compiling using CGO --- build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 1097da7..5ea29a4 100755 --- a/build.sh +++ b/build.sh @@ -19,7 +19,6 @@ GO_BUILD_OPTIONS=-v #GO_BUILD_OPTIONS="-a -v" DEFAULT_TARGET=amd64 - ####################################################################################### # functions @@ -35,17 +34,25 @@ usage() { build_linux_amd64() { echo -e "\nBuilding for Linux amd64:" + env GOOS=linux GOARCH=amd64 go build ${GO_BUILD_OPTIONS} -ldflags "$(govvv -flags)" -o ${APP}-linux-amd64 echo -e "\t\t${GREEN}... done${NC}" } build_linux_arm() { echo -e "\nBuilding for arm:" + + # setup environment + export CGO_ENABLED=1 + export PATH=$PATH:/opt/devel/ptu4/buildrootBuild/host/usr/bin + export CC=arm-linux-gcc + export PKG_CONFIG_PATH=/opt/devel/ptu4/buildrootBuild/host/usr/lib/pkgconfig + env GOOS=linux GOARCH=arm go build ${GO_BUILD_OPTIONS} -ldflags "$(govvv -flags)" -o ${APP}-linux-arm echo -e "\t\t${GREEN}... done${NC}" echo -e "\nstipping arm binary:" - strip -o ${TARGET}-linux-arm-stripped ${TARGET}-linux-arm + strip -o ${TARGET}-linux-arm-stripped ${APP}-linux-arm echo -e "\t\t${GREEN}... done${NC}" }