skip to Main Content

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 ?

2

Answers


  1. Chosen as BEST ANSWER

    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)
    

    Hope it helps.


  2. While @Duddy67’s answer works, I want to discuss an alternate approach. Generally, it is bad practice to use a system-wide installation of libraries for your projects as they create dependencies on the system configuration, require complex setup steps, and have the potential for versioning conflicts.

    Instead, you should download the libraries directly to your project repository. Users in the future can then simply replicate your project environment by downloading the necessary dependencies, rather than your entire system environment.

    Local Project Solution:

    git clone https://github.com/PortAudio/portaudio      #step 1
    cd portaudio                                          #step 2
    ./configure                                           #step 3
    make                                                  #step 4
    sudo make install                                     #step 5
    

    Now, to check that it is correctly installed, we can search for the file:

    sudo ldconfig                                         #step 1
    ldconfig -p | grep portaudio                          #step 2
    

    Your output should be something like below:

    libportaudio.so.2 (libc6,x86-64) => /usr/local/lib/libportaudio.so.2
    libportaudio.so (libc6,x86-64) => /usr/local/lib/libportaudio.so
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search