Search code examples
rubyubuntulibsndfile

Trying to install libsndfile on Ubuntu 16


I've tried running

sudo apt-get install libsndfile
> E: Unable to locate package libsndfile

So then I try

sudo apt-get install libsndfile1

It installs, but where, how?

find /usr/ -name libsndfile*
> /usr/lib/x86_64-linux-gnu/libsndfile.so.1
> /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25

At the end of the day my goal is to get the lib to work for ruby, with either:

gem install sndfile
gem install ruby-audio

When I try installing ruby-audio, I get:

extconf.rb:21:in `<main>':   Can't find libsndfile (http://www.mega-nerd.com/libsndfile/) (RuntimeError)

So for some reason the library doesn't install properly.


Solution

  • When you want to compile something against a library you'll need not only the library itself, which is usually one or more .so type files, but the header files that describe how the library works. These are often omitted unless you install the -dev version of the package:

    apt-get install libsndfile-dev
    

    This should give the Ruby extconf.rb enough information to compile and link against that library.