I need to use OpenBLAS (very popular in scientific community). “making” this on an X86 development machine works perfectly and I can call functions from go. However, I need this on an ARM linux target. So, I’ve done this:
Find all installed packages for the ARM compiler: sudo aptitude search arm-linux-gnueabi
Purge ALL gnueabi versions: sudo apt-get purge --auto-remove gfortran-arm-linux-gnueabi, etc for any "installed"
Install only gnueabihf versions: sudo aptitude install gfortran-arm-linux-gnueabihf (this also installs gnueabihf gcc)
From the OpenBLAS directory: make CC=arm-linux-gnueabihf-gcc FC=arm-linux-gnueabihf-gfortran HOSTCC=gcc TARGET=CORTEXA9
Install the ARM libs: sudo make PREFIX=/usr/local install
The make runs to completion and I can install the ARM OpenBLAS library. I followed similar steps to get FFTW to cross-compile if anyone is interested.
Next, installing go for cross-compiling I did this:
export CGO_ENABLED=1
export CC_FOR_TARGET=arm-linux-gnueabihf-gcc
export GOGCCFLAGS="-fPIC -pthread -mfpu=vfp -mfloat-abi=hard --static"
export GOOS=linux
export GOARCH=arm
export GOARM=7
bash ./all.bash
go env shows:
GOARCH=“arm"
GOBIN=”“
GOEXE=”"
GOHOSTARCH=“amd64"
GOHOSTOS=“linux"
GOOS=“linux"
GOPATH=”/opt/Projects/Golang"
GORACE=”“
GOROOT=”/usr/local/go"
GOTOOLDIR=”/usr/local/go/pkg/tool/linux_amd64"
CC=“arm-linux-gnueabihf-gcc"
GOGCCFLAGS=”-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build149148529=/tmp/go-build -gno-record-gcc-switches"
CXX=“g++“
CGO_ENABLED=“1"
Notice the GOGCCFLAGS get mangled (see golang go issues 8161). I can work around that by specifying GOGCCFLAGS on the command line:
GOOS=linux GOARCH=arm GOARM=7 GOGCCFLAGS=”-fPIC -pthread -mfpu=vfp -mfloat-abi=hard --static” CC=arm-linux-gnueabihf-gcc CGO_LDFLAGS=”-L/usr/local/lib -lopenblas " go build -x rand_zgeev.go
However, when I copy this to the arm system, it does not run:
./rand_zgeev
-sh: ./rand_zgeev: not found
I think the library is correct (cross-compiled for ARM w/o errors and installed in /usr/local/lib).
Here is a verbose build command – maybe it will show where I’m going wrong?
Hi Dave -
Can you tell from my build details (next post) what’s wrong? Everything seems to build w/o errors, but it does not load on target (ArmCortexA8)
Any suggestions? I’m stuck.
Thanks for the pointers – I’ll try it on my next work day. I’m not sure it will work, but it’s certainly worth a try! I’m not sure the OpenBLAS library will link to get the right executable, but I’m confident it’s “good” since the lengthy build process showed no warnings or errors. I’ll let you know how it goes.