你好。
請問 toolchain 中,有沒有 ALSA 的 lib, include 支援呢?
我寫一個簡單的程式,如下:
可是編譯的時候,會出現
main.c:3:28: fatal error: asla/asonudlib.h: No such file or directory
錯誤。
我知道可以使用 -I -L 來指定 include path , lib ... 但是請問:
toolchain 本身有支援這些 Lib 嗎?
如果有,應該如何設定編譯參數呢?
如果沒有。我自己有使用 crosss-compiler 編譯好 alsa 。也都成功,沒有錯誤。請問應該如何將我編譯好的 lib, include . 加入到 toolcahin 中呢?
謝謝
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
main (int argc, char *argv[])
{
int i;
int err;
short buf[128];
snd_pcm_t *playback_handle;
snd_pcm_hw_params_t *hw_params;
/* Open the device */
snd_pcm_open (&playback_handle, argv[1], SND_PCM_STREAM_PLAYBACK, 0);
/* Allocate Hardware Parameters structures and fills it with config space for PCM */
snd_pcm_hw_params_malloc (&hw_params);
snd_pcm_hw_params_any (playback_handle, hw_params);
/* Set parameters : interleaved channels, 16 bits little endian, 44100Hz, 2 channels */
snd_pcm_hw_params_set_access (playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format (playback_handle, hw_params, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, 44100, 0);
snd_pcm_hw_params_set_channels (playback_handle, hw_params, 2);
/* Assign them to the playback handle and free the parameters structure */
snd_pcm_hw_params (playback_handle, hw_params);
snd_pcm_hw_params_free (hw_params);
/* Prepare & Play */
snd_pcm_prepare (playback_handle);
for (i = 0; i < 10; i++) {
if ((err = snd_pcm_writei (playback_handle, buf, 128)) != 128) {
(...)
}
}
/* Close the handle and exit */
snd_pcm_close (playback_handle);
exit (0);
}