grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.54k stars 319 forks source link

Issue with alsa/asoundlib.h and gtk/gtk.h when compiling #562

Closed jrgehrig closed 3 years ago

jrgehrig commented 3 years ago

I have been trying to compile the physical modelling piano example from examples/physicalModeling/faust-stk on Ubuntu Linux. I have been using the commands from the using the compiler page, i.e.

faust -a alsa-gtk.cpp noise.dsp -o noise.cpp
g++ -lpthread -lasound `pkg-config --cflags --libs gtk+-2.0` noise.cpp -o noise

But when I do so I get the error

In file included from piano.cpp:58:
/usr/local/include/faust/audio/alsa-dsp.h:34:10: fatal error: alsa/asoundlib.h: No such file or directory
   34 | #include <alsa/asoundlib.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

Opening the piano.cpp file in Visual Studio Code shows two include errors: cannot open source file "gtk/gtk.h" (dependency of "faust/gui/GTKUI.h") and cannot open source file "alsa/asoundlib.h"

I attempted to fix the ALSA error myself by downloading alsa-lib-1.2.4.tar.bz2 from here (also note that the link for "wide range of compilation scripts" is broken), extracting it to my user directory, and running ./configure and make install as instructed in the INSTALL file, but I get the following errors:

Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/include/alsa/sound/uapi'
/usr/bin/mkdir: cannot create directory ‘/usr/include/alsa’: Permission denied

How do I fix these issues? What do I need to do about the gtk/gtk.h file?

jrgehrig commented 3 years ago

I can't get one of my links above to work; the ALSA library was downloaded from here

sletz commented 3 years ago

Why not directly using the te faust2alsa script ? https://faustdoc.grame.fr/manual/tools/#faust2alsa

jrgehrig commented 3 years ago

The issue seems to still be that the alsa and gtk files are missing. Running that script gives a new set of errors:

Package alsa was not found in the pkg-config search path.
Perhaps you should add the directory containing `alsa.pc'
to the PKG_CONFIG_PATH environment variable
No package 'alsa' found
piano.dsp.cpp:4073:10: fatal error: gtk/gtk.h: No such file or directory
 4073 | #include <gtk/gtk.h>
      |          ^~~~~~~~~~~
compilation terminated.

I am still not sure what to do about adding alsa and gtk to my system to get this working

sletz commented 3 years ago

Probably adding development packages for both of them.