主题 : 請問 toolchain 中,有沒有 ALSA 的 lib, include 支援呢? 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 37502
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
综合积分: 96 分
注册时间: 2011-02-11
最后登录: 2011-09-06
楼主  发表于: 2011-03-03 21:20

 請問 toolchain 中,有沒有 ALSA 的 lib, include 支援呢?

你好。
請問 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);
}
自由,自强,共享,共创。
级别: 论坛版主
UID: 12573
精华: 27
发帖: 8838
金钱: 46490 两
威望: 9298 点
综合积分: 18216 分
注册时间: 2010-01-09
最后登录: 2019-07-16
1楼  发表于: 2011-03-03 21:30
4.5.1中有
新手如何向我们反馈有效的信息,以便解决问题,见此贴:
http://www.arm9home.net/read.php?tid-14431.html

[注]: 此处签名链接仅为指引方向,而非解答问题本身.
级别: 新手上路
UID: 37502
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
综合积分: 96 分
注册时间: 2011-02-11
最后登录: 2011-09-06
2楼  发表于: 2011-03-04 15:24
謝謝。我目前就是使用 4.5.1 。但是 #include <alsa/asoundlib.h> 會出錯:

main.c:3:28: fatal error: asla/asonudlib.h: No such file or directory

猜想是因為我沒有正確的設定 -I -L -l  參數。請問該指到那個目錄呢?

謝謝您。
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
3楼  发表于: 2011-03-04 15:38
你用4.5.1,只需要指定-lasound就可以了
如果不行,则肯定是其它原因
级别: 新手上路
UID: 37502
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
综合积分: 96 分
注册时间: 2011-02-11
最后登录: 2011-09-06
4楼  发表于: 2011-03-04 16:41
只要指定 -lasound (使用 asound lib) 就好嗎? 不用指定 -I 目錄嗎?因為我編譯時:

arm-linux-gcc  -lasound main.c

還是會出現

main.c:3:28: fatal error: asla/asonudlib.h: No such file or directory
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
5楼  发表于: 2011-03-04 17:08
你运行
arm-linux-gcc -v
把打印信息贴出来看看
级别: 新手上路
UID: 37502
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
综合积分: 96 分
注册时间: 2011-02-11
最后登录: 2011-09-06
6楼  发表于: 2011-03-04 17:34
信息是:


[root@localhost ex_1]# arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolschain/4.5.1/libexec/gcc/arm-none-linux-gnueabi/4.5.1/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /work/toolchain/build/src/gcc-4.5.1/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.5.1 --with-sysroot=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --enable-languages=c,c++ --disable-multilib --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=softfp --with-pkgversion=ctng-1.8.1-FA --with-bugurl=http://www.arm9.net/ --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-gmp=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpfr=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-ppl=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-cloog=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpc=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-libelf=/work/toolchain/build/arm-none-linux-gnueabi/build/static --enable-threads=posix --with-local-prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.5.1 (ctng-1.8.1-FA)
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
7楼  发表于: 2011-03-04 17:48
编译器没有问题

看你贴出来的信息,
main.c:3:28: fatal error: asla/asonudlib.h: No such file or directory

应该是alsa/asoundlib.h 吧?
级别: 新手上路
UID: 37502
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
综合积分: 96 分
注册时间: 2011-02-11
最后登录: 2011-09-06
8楼  发表于: 2011-03-04 17:53
對不起各位。是我白癡,打錯字,勞煩各位費心協助。非常抱歉。也非常感謝