Home » Android » android – Cannot find alsa/asoundlib.h

android – Cannot find alsa/asoundlib.h

Posted by: admin June 15, 2020 Leave a comment


While building my Android source code I get this error

cannot find alsa/asoundlib.h

I have already installed libasound2-dev. asoundlib.h is present in usr/include/alsa/ folder
but still the builder is not able to find it.

Can anyone tell me that why the compiler is not able to find asoundlib.h?
How to add /usr/include to the search path for header files?

How to&Answers:

If you’re using debian or ubuntu then running apt-get install libasound2-dev solves the problem. It installs the needed header files, though you might run into some version incompatibilities. (In which case, the solution is to go back to source and find it.)

Additionally, the package names would vary for different OS versions.
In generally if the development libraries are installed you should be able to find it by running locate asoundlib.h command.


I had the problem then I found the solution.
In external/alsa-lib include they have all the libraries for the alsa-util compiles. However the alsa-util compiles or other alsa related programs are looking for alsa/*.h libraries where as all the *.h are in the include folder.

Create an alsa folder within the external/alsa-lib/include/ then copy all needed libraries should solve the problem.


Did you get your source code from a Subversion repository?

I had the same issue, as i checked out the source code from an unofficial Subversion repository. So I first installed libasound2-dev and copied the directory /usr/include/alsa to the directory external/qemu/alsa as you and Peter Ju proposed. But after that another error occurred:

make: *** No rule to make target 'prebuilt/linux-x86/sdl/lib/libSDL.a', needed by 'out/host/linux-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a'.  Stop.

After some research I found out that some static libraries in the prebuilt folder were missing, because Subversion ignores some specific file extensions. After getting these files, everything worked well…

Don’t know if this will do trick in your case but maybe it is the ‘missing link’ for you or someone else…