debianportaudio

Portaudio cannot find libportaudio.a


I've installed portaudio on Debian:
sudo apt install portaudio19-dev
Now I'm trying to run a test program to make sure it works:
gcc pa_devs.c libportaudio.a -lrt -lm -lasound -o pa_devs

But I get this error:
/usr/bin/ld: cannot find libportaudio.a: No such file or directory

Here's where Debian installed the portaudio files:

/usr/include/portaudiocpp
/usr/include/portaudiocpp/PortAudioCpp.hxx
/usr/include/portaudio.h
/usr/lib/x86_64-linux-gnu/libportaudiocpp.a
/usr/lib/x86_64-linux-gnu/pkgconfig/portaudio-2.0.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/portaudiocpp.pc
/usr/lib/x86_64-linux-gnu/libportaudiocpp.so
/usr/lib/x86_64-linux-gnu/libportaudio.a
/usr/lib/x86_64-linux-gnu/libportaudio.so.2.0.0
/usr/lib/x86_64-linux-gnu/libportaudio.so
/usr/lib/x86_64-linux-gnu/libportaudiocpp.so.0
/usr/lib/x86_64-linux-gnu/libportaudiocpp.so.0.0.12
/usr/lib/x86_64-linux-gnu/libportaudio.so.2
/usr/share/doc/libportaudio2
/usr/share/doc/portaudio19-dev
/usr/share/doc/libportaudiocpp0

how can I tell gcc the correct path to the library ?


Solution

  • For those who are interested:

    gcc pa_devs.c /usr/lib/x86_64-linux-gnu/libportaudio.a -lrt -lm -lasound -o pa_devs
    

    For other programs that require the jack library:

    gcc pa_devs.c /usr/lib/x86_64-linux-gnu/libportaudio.a -ljack -lrt -lm -lasound -o pa_devs
    

    A possible alternative is to compile programs with the shared library (.so) instead of the static library (.a):

    gcc pa_devs.c -o pa_devs $(pkg-config --cflags --libs portaudio-2.0)