I am trying to write a PulseAudio module. To start, first, I wrote the following minimal code for a module as mentioned by this documentation.
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
I tried compiling it with this command:
gcc -g -shared -o module-test.so module-test.c
But it gives error:
pulsecore/module.h: No such file or directory
#include <pulsecore/module.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
After searching on the internet, I found that I have to installed libpulse-dev
, but I have already installed pulseaudio
and libpulse-dev
as you can see below.
jyotesh@jyotesh-VM:~$ sudo apt install pulseaudio libpulse-dev
[sudo] password for jyotesh:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpulse-dev is already the newest version (1:11.1-1ubuntu7.2).
pulseaudio is already the newest version (1:11.1-1ubuntu7.2).
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
I have tried searching for the header file using locate
, find
, apt-file
, etc. I am not able to find where this header file is.
Does anyone know how to compile the PulseAudio module?
I was able to compile the code and build module-test.so
file by following the steps from here and here. I will repeat the steps here:
First, I built and installed PulseAudio v12.2 from the source code.
# Clone PulseAudio git repository
git clone https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
# I wanted 12.2 version of PulseAudio, so I checked out that version
cd pulseaudio
git checkout tags/v12.2
# Install the dependencies
sudo apt-get -y build-dep pulseaudio
# Build PulseAudio source code
./bootstrap.sh
make
# Install and configure dynamic linker run-time bindings (so that
# ld can find the libraries that you specify while building your module)
sudo make install
sudo ldconfig
After this, I wrote minimal code for a module.
#include <config.h> // this is required, otherwise you will get compilation errors
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
To compile this, I used the command
gcc -g -shared -fPIC -I/home/jyotesh/pulseaudio -I/home/jyotesh/pulseaudio/src -L/home/jyotesh/pulseaudio/.libs -L/usr/local/lib/pulseaudio -o module-test.so module-test.c -lpulsecore-12.2 -lpulsecommon-12.2 -lpulse