Closed masseelch closed 3 years ago
Nervermind. I had an issue with my go-path. I am sorry! Everything works like it should.
Me again. The issue still is there when trying to cross compile for arm. It does happen for all version (5,6,7).
Hi @masseelch. I haven't tried cross-compiling for ARM. However, you will probably have to cross compile libvlc
itself first and I'm not sure that's such an easy task.
As for cross-compiling a Go application using libvlc-go
, you will need to install an ARM compiler like arm-linux-gnueabi-gcc
or arm-linux-gnueabi-g++-7
(which you'll probably already have because you'll need it for compiling libvlc
) and then do something like:
CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build
In my case I want to build for raspberry pi and there is a precombiled version of libvlc
on the latest raspberry pi os i can use.
I however did just now learn about cgo
. I will try to go down that road an report. Thanks for the directions!
No problem. Let me know how it goes.
Progress so far:
I downloaded the official crosscompiling tools and linked the header files and library already present on the latest raspberrypios buster.
The build itself is succeeding i think, but there are linker errors i have to resolve yet.
» CPATH=/workspace/libvlc-go/include LD_LIBRARY_PATH=/workspace/libvlc-go/lib CC=/workspace/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build main.go
# github.com/adrg/libvlc-go/v3
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
/home/jcl/Code/display/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lvlc
collect2: error: ld returned 1 exit status
If you have any ideas I'd appreciate.
Is /workspace/libvlc-go/lib
the location of the libvlc.so
shared library compiled for ARM? If so, you can try adding
CGO_LDFLAGS="-L/workspace/libvlc-go/lib"
in your build command:
CPATH=/workspace/libvlc-go/include CGO_LDFLAGS="-L/workspace/libvlc-go/lib" LD_LIBRARY_PATH=/workspace/libvlc-go/lib CC=/workspace/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build main.go
Yes, this resolved the linker issue but got me a new one.
warning: libvlccore.so.9, needed by /workspace/libvlc-go/lib/libvlc.so, not found
ibvlccore.so.9
is present in the same dir as libvlc.so
. I look at that tomorrow. Thanks a lot for your help!
The same happens when i tried building with dockercross.
CGO_LDFLAGS="-Wl,-L/workspace/libvlc-go/lib,-rpath=/workspace/libvlc-go/lib"
solved that issue but know it complains about missing libidn.so.11
and libdbus-1.so.3
...
After adding in all required libraries I detected, that the tools i mentioned above had been compiled with GLIBC@2.23
which are no longer suitable for gcc7
and above. However this repo had the correct toolchain and with it and rpath-link
everything works (at least on RPI3, didnt test on RPI4 yet).
Thank you for your help.
For anyone landing here:
CPATH=/workspace/libvlc-go/include CC=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-gcc CGO_LDFLAGS="-Wl,-L/workspace/libvlc-go/lib,-rpath-link=/workspace/libvlc-go/lib" CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build main.go
I tried to run this but the build fails with
I use Kernel 5.4.116-1-MANJARO.