Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build BaseExample #74

Closed
masseelch opened this issue May 19, 2021 · 10 comments
Closed

Cannot build BaseExample #74

masseelch opened this issue May 19, 2021 · 10 comments

Comments

@masseelch
Copy link

masseelch commented May 19, 2021

I tried to run this but the build fails with

# command-line-arguments
cmd/client/main.go:34:12: undefined: vlc.Init
cmd/client/main.go:37:8: undefined: vlc.Release
cmd/client/main.go:40:17: undefined: vlc.NewPlayer
» gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
» ls /usr/lib | grep libvlc
libvlccore.so
libvlccore.so.9
libvlccore.so.9.0.0
libvlc.so
libvlc.so.5
libvlc.so.5.6.0

I use Kernel 5.4.116-1-MANJARO.

@masseelch
Copy link
Author

Nervermind. I had an issue with my go-path. I am sorry! Everything works like it should.

@masseelch
Copy link
Author

Me again. The issue still is there when trying to cross compile for arm. It does happen for all version (5,6,7).

@masseelch masseelch reopened this May 19, 2021
@adrg
Copy link
Owner

adrg commented May 19, 2021

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

@masseelch
Copy link
Author

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!

@adrg
Copy link
Owner

adrg commented May 19, 2021

No problem. Let me know how it goes.

@masseelch
Copy link
Author

masseelch commented May 19, 2021

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.

@adrg
Copy link
Owner

adrg commented May 19, 2021

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

@masseelch
Copy link
Author

masseelch commented May 19, 2021

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.

@masseelch
Copy link
Author

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 ...

@masseelch
Copy link
Author

masseelch commented May 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants