GithubHelp home page GithubHelp logo

Add installation instructions? about go-lame HOT 9 CLOSED

viert avatar viert commented on June 2, 2024
Add installation instructions?

from go-lame.

Comments (9)

sendqueery avatar sendqueery commented on June 2, 2024 2

For anyone reading this in the future, if you just run brew install lame, it'll sort the dependency.

from go-lame.

olup avatar olup commented on June 2, 2024 2

Of course!

So on Ubuntu or macOS intel, all I had to do is install lame.

Ubuntu:

sudo apt-get install -y libmp3lame-dev

macOS x86

brew install lame

It's because on those two platform, the package manager directory is in the sysroot path (the place the compiler will look to find headers and libraries). Unfortunately, brew's install directory on macOS arm is not in the sysroot, so you just have to point it yourself. So after having installed lame with brew, on an M1, I also used environment variables to set the compilers flags:

export CGO_LDFLAGS="-L/opt/homebrew/opt/lame/lib" (for the lib part)
export CGO_CFLAGS="-I/opt/homebrew/opt/lame/include" (for the include part)

With those two environment variables set, you should be able to build.

Side note:

I also wanted to statically build my program, so that the end user would not have to install lame on her mac for the program to work (lame would be "bundled" with my code). Complete static linking seems impossible on macos, so I could not use the static flag. By default the compiler will take the dynamic lame lib in /opt/homebrew/opt/lame/lib. The trick for me was just to delete the .dylib lame file in this directory - the compiler will then take the static library to build. This is a bit of a hack and I think you can point the compiler to the specific lib file, but I could not find how :-)

from go-lame.

RobinKamps avatar RobinKamps commented on June 2, 2024

Under win10 i got the error: .....ld.exe: cannot find -lmp3lame .....
I have tried it with tdm-gcc and ming-gw64 and put the whole lame folder from https://sourceforge.net/projects/lame/files/lame/3.100/ under all search include folders - but no success.

How to add the lame library to your linker under win10?

under ubuntu i got copied lame.h to /home/...../go/pkg/mod/github.com/viert/[email protected]/
to resolve the issue:

# github.com/viert/lame
/home/...../go/pkg/mod/github.com/viert/[email protected]/lame.go:7:10: fatal error: lame/lame.h: No such file or directory
    7 | #include "lame/lame.h"
      |          ^~~~~~~~~~~~~

but i get a new one:

/usr/bin/x86_64-w64-mingw32-ld: cannot find -lmp3lame

does anyone knows how to solve the compiling issues (especially under win10)?

from go-lame.

viert avatar viert commented on June 2, 2024

Sorry for being silent for so long, mates.

On Ubuntu the building process is easy as hell, you need to install libmp3lame-dev package to get the library and the headers:

p.vorobyov@xenial:~/src/go/go-lame$ sudo apt install libmp3lame-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libmp3lame0
The following NEW packages will be installed:
  libmp3lame-dev libmp3lame0
0 upgraded, 2 newly installed, 0 to remove and 318 not upgraded.
Need to get 269 kB of archives.
After this operation, 816 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ru.archive.ubuntu.com/ubuntu xenial/universe amd64 libmp3lame0 amd64 3.99.5+repack1-9build1 [127 kB]
Get:2 http://ru.archive.ubuntu.com/ubuntu xenial/universe amd64 libmp3lame-dev amd64 3.99.5+repack1-9build1 [142 kB]
Fetched 269 kB in 0s (368 kB/s)
Selecting previously unselected package libmp3lame0:amd64.
(Reading database ... 155491 files and directories currently installed.)
Preparing to unpack .../libmp3lame0_3.99.5+repack1-9build1_amd64.deb ...
Unpacking libmp3lame0:amd64 (3.99.5+repack1-9build1) ...
Selecting previously unselected package libmp3lame-dev:amd64.
Preparing to unpack .../libmp3lame-dev_3.99.5+repack1-9build1_amd64.deb ...
Unpacking libmp3lame-dev:amd64 (3.99.5+repack1-9build1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libmp3lame0:amd64 (3.99.5+repack1-9build1) ...
Setting up libmp3lame-dev:amd64 (3.99.5+repack1-9build1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
p.vorobyov@xenial:~/src/go/go-lame$ go build
p.vorobyov@xenial:~/src/go/go-lame$

With win10 I'm going to need some more time to see how it's done on windows. But the main idea is you are to have the header file AND the library itself. The header is used for compiling while the library is used throughout linking process

from go-lame.

RobinKamps avatar RobinKamps commented on June 2, 2024

Hey thank you for the very fast response.

unfortunately i need to build this for win - i tried to compile it under win and to cross compile it under ubuntu.
Your answer is correct to build it under ubuntu for linux.
But when i cross compile for win i get the same error as on win itself:

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build
# github.com/viert/lame
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lmp3lame
collect2: error: ld returned 1 exit status

from go-lame.

sendqueery avatar sendqueery commented on June 2, 2024

It looks like there's a pretty detailed post on the subject that might be helpful: https://dh1tw.de/2019/12/cross-compiling-golang-cgo-projects/

Trying the pacman stuff might also allow you to just build it natively on W10? Worth a shot, at least. :)

from go-lame.

olup avatar olup commented on June 2, 2024

Hey, reviving this issue, on macos I can't build my project using go-lame as it's missing "lame/lame.h". Not familiar with c binding and I did install lame with brew according to the comment on top - not to avail. Any thoughts on where to put the lame source ?

from go-lame.

olup avatar olup commented on June 2, 2024

Actually, I found out : I needed to set the compiler flag so that it could look in the the bin and lib directory where brew had installed lame.

from go-lame.

daniel-sullivan avatar daniel-sullivan commented on June 2, 2024

Actually, I found out : I needed to set the compiler flag so that it could look in the the bin and lib directory where brew had installed lame.

@olup Would you mind sharing the flags you ended up using? (it might help others with this same issue)

from go-lame.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.