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 find -lasound #129

Closed
Cheb-design opened this issue Nov 11, 2020 · 6 comments
Closed

cannot find -lasound #129

Cheb-design opened this issue Nov 11, 2020 · 6 comments

Comments

@Cheb-design
Copy link

Cheb-design commented Nov 11, 2020

Hi,
I use faiface/beep library with Oto under the hood. And everything is fine except cross compilation to arm machine.
Now I am trying to compile code on linux/amd64 virtual machine to linux/arm. I did so:

$ CC=arm-linux-gnueabi-gcc GOOS=linux GOARCH=arm CGO_ENABLED=1 go build hello.go

And output was:

# github.com/hajimehoshi/oto
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status

I tried this both on virtual and stand alone xubuntu machines with the same error.
arm-linux-gnueabihf-gcc - the same error
libasound2-dev is installed and locally all works fine
GOARM setting has no any effect

Could you help please with this issue?

Best regards and thanks for great lib!

@hajimehoshi
Copy link
Member

Unfortunately it is hard or impossible to cross-compile Oto for other architectures due to Cgo. I have no idea about a good solution.

@gen2brain
Copy link

@Cheb-design You need libasound/alsa-lib compiled for arm, you cannot link arm binary with x86_64 lib. Just compile alsa-lib with your arm gcc, and install in toolchain sysroot/lib directory.

@Cheb-design
Copy link
Author

@Cheb-design You need libasound/alsa-lib compiled for arm, you cannot link arm binary with x86_64 lib. Just compile alsa-lib with your arm gcc, and install in toolchain sysroot/lib directory.

Thanks for idea! I'll try it

@kpeu3i
Copy link

kpeu3i commented Mar 21, 2021

@Cheb-design Did you have any success with the issue? I got absolutely the same error.

@kpeu3i
Copy link

kpeu3i commented Mar 26, 2021

Cross-compiling inside the docker container might help:

  1. Create Dockerifle:
FROM karalabe/xgo-1.13

ENV ALSA_LIB_VERSION=1.2.4

RUN apt-get update && apt-get install -y \
    curl

RUN mkdir /alsa && \
    curl "ftp://ftp.alsa-project.org/pub/lib/alsa-lib-${ALSA_LIB_VERSION}.tar.bz2" -o /alsa/alsa-lib-${ALSA_LIB_VERSION}.tar.bz2

# https://www.programering.com/a/MTN0UDMwATk.html
# https://stackoverflow.com/questions/36195926/alsa-util-1-1-0-arm-cross-compile-issue
RUN cd /alsa && \
    tar -xvf alsa-lib-${ALSA_LIB_VERSION}.tar.bz2 && \
    cd alsa-lib-${ALSA_LIB_VERSION} && \
    CC=arm-linux-gnueabihf-gcc-5 ./configure --host=arm-linux && \
    make && \
    make install
  1. Build image
docker build -t cross-compile-utils .
  1. Compile your app:
docker run -it --rm --entrypoint="" -v $(pwd):/app -v ~/go/pkg/mod:/go/pkg/mod -w /app cross-compile-utils bash -c '\
                CC=arm-linux-gnueabihf-gcc-5 \
                GOOS=linux \
                GOARCH=arm \
                GOARM=7 \
                CGO_ENABLED=1 \
                go build -i'

@hajimehoshi
Copy link
Member

Let me close this. Feel free to reopen if you still have a question.

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

4 participants