【嵌入式】交叉编译 移植 ALSA1.2.2

一、开发环境

开发环境:ubuntu16.04
开发平台:imx6q
交叉编译工具链:arm-linux-gnueabihf

二、需要的软件

1、alsa-lib

下载地址:alsa-lib
版本:alsa-lib-1.2.2.tar.bz2

2、alsa-utils

下载地址:alsa-utils
版本:alsa-utils-1.2.2.tar.bz2

三、交叉编译移植alsa-lib

导入环境变量:

export PATH=/usr/lib/gcc/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin:$PATH

1、准备工作

①、创建安装文件夹

这个文件夹是用来放置编译出来的相关库文件

mkdir alsa-lib

②、拷贝到ubuntu

cp /media/sf_share/6q/alsa/alsa-lib-1.2.2.tar.bz2 .

③、解压alsa-lib-1.2.2.tar.bz2

tar xvf alsa-lib-1.2.2.tar.bz2

④、进入目录

cd alsa-lib-1.2.2

【嵌入式】交叉编译 移植 ALSA1.2.2_第1张图片

2、配置生成Makefile

注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!

sudo su
source /etc/profile

配置解读
1、–host 指定编译器,这里指定为交叉编译器
2、–prefix 指定编译后文件的安装路径
3、–with-configdir 指定 conf 文件的安装目录

./configure --host=arm-linux-gnueabihf --prefix=/home/icedustpan/software/alsa/alsa-lib --with-configdir=/usr/local/alsa

3、编译

make

4、安装

make install

【嵌入式】交叉编译 移植 ALSA1.2.2_第2张图片

安装成功退出 root用户

exit

5、特别提示

注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!

Libraries have been installed in:
   /home/icedustpan/software/alsa/alsa-lib/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src'
make[2]: Leaving directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src'
make[1]: Leaving directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src'
Making install in src/topology
make[1]: Entering directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src/topology'
make[2]: Entering directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src/topology'
 /bin/mkdir -p '/home/icedustpan/software/alsa/alsa-lib/lib'
 /bin/bash ../../libtool   --mode=install /usr/bin/install -c   libatopology.la '/home/icedustpan/software/alsa/alsa-lib/lib'
libtool: warning: relinking 'libatopology.la'
libtool: install: (cd /home/icedustpan/software/alsa/alsa-lib-1.2.3/src/topology; /bin/bash "/home/icedustpan/software/alsa/alsa-lib-1.2.3/libtool"  --silent --tag CC --mode=relink arm-linux-gnueabihf-gcc -version-info 2:0:0 -Wl,--version-script=../Versions -Wl,-z,defs -o libatopology.la -rpath /home/icedustpan/software/alsa/alsa-lib/lib parser.lo builder.lo ctl.lo dapm.lo pcm.lo data.lo text.lo channel.lo ops.lo elem.lo save.lo decoder.lo log.lo ../libasound.la )
/home/icedustpan/software/alsa/alsa-lib-1.2.3/libtool: line 10533: arm-linux-gnueabihf-gcc: command not found
libtool:   error: error: relink 'libatopology.la' with the above command before installing it
Makefile:407: recipe for target 'install-libLTLIBRARIES' failed
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src/topology'
Makefile:595: recipe for target 'install-am' failed
make[1]: *** [install-am] Error 2
make[1]: Leaving directory '/home/icedustpan/software/alsa/alsa-lib-1.2.3/src/topology'
Makefile:404: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

5、移植到arm

①、拷贝lib

把 --prefix指定的路径下的 /lib 下的全部文件拷贝到 arm 文件系统的 /usr/lib/目录中

当时我指定了:

--prefix=/home/icedustpan/software/alsa/alsa-lib

进入/home/icedustpan/software/alsa/alsa-lib

cd /home/icedustpan/software/alsa/alsa-lib/lib

【嵌入式】交叉编译 移植 ALSA1.2.2_第3张图片
我的arm文件系统的路径:/home/icedustpan/buildroot-2020.05.1/output/images/rootfs/

拷贝

sudo cp * /home/icedustpan/buildroot-2020.05.1/output/images/rootfs/usr/lib/ -rf
②、拷贝 with-configdir

把 --with-configdir指定的目录的所有内容(主要是alsa.conf)拷贝 到 arm 文件系统的相同的路径中

当时我指定了:

--with-configdir=/usr/local/alsa

进入/usr/local/alsa

cd /usr/local/alsa

后面我们要配置 alsa.conf ,请记住 拷贝的 alsa.conf 路径!!!
后面我们要配置 alsa.conf ,请记住 拷贝的 alsa.conf 路径!!!
后面我们要配置 alsa.conf ,请记住 拷贝的 alsa.conf 路径!!!
【嵌入式】交叉编译 移植 ALSA1.2.2_第4张图片
我的arm文件系统的路径:/home/icedustpan/buildroot-2020.05.1/output/images/rootfs/

拷贝

sudo cp * /home/icedustpan/buildroot-2020.05.1/output/images/rootfs/usr/local/alsa/ -rf

四、交叉编译移植alsa-utils

注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!

1、准备工作

①、创建安装文件夹

这个文件夹是用来放置编译出来的相关库文件

mkdir alsa-utils

②、拷贝到ubuntu

cp /media/sf_share/6q/alsa/alsa-utils-1.2.3.tar.bz2 .

③、解压alsa-utils-1.2.3.tar.bz2

tar xvf alsa-utils-1.2.3.tar.bz2

④、进入目录

cd alsa-utils-1.2.3

【嵌入式】交叉编译 移植 ALSA1.2.2_第5张图片

2、配置生成Makefile

注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!
注意:编译安装操作步骤,请在root用户下执行!!!!

sudo su
source /etc/profile
./configure --host=arm-linux-gnueabihf --prefix=/home/icedustpan/software/alsa/alsa-utils --with-alsa-inc-prefix=/home/icedustpan/software/alsa/alsa-lib/include CFLAGS="-I/home/icedustpan/software/alsa/alsa-lib/include" LDFLAGS="-L/home/icedustpan/software/alsa/alsa-lib/lib -lasound" --disable-alsamixer --disable-xmlto

配置解读:
1、–host:交叉编译工具链
2、–prefix:安装路径
3、–with-alsa-inc-prefix:前面交叉编译的 alsa-lib的 include 文件夹
4、CFLAGS:前面交叉编译的 alsa-lib的 include 文件夹
5、LDFLAGS:前面交叉编译的 alsa-lib的 lib 文件夹

3、编译

make

4、安装

make install

【嵌入式】交叉编译 移植 ALSA1.2.2_第6张图片

5、特别提示

注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!
注意:如果不在 root用户下执行 将会报错 !!!请切换到root用户执行!!!

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-gnueabihf-strip... arm-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for a sed that does not truncate output... /bin/sed
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking whether make supports the include directive... yes (GNU style)
checking for arm-linux-gnueabihf-gcc... arm-linux-gnueabihf-gcc
checking whether the C compiler works... no
configure: error: in `/home/icedustpan/software/alsa/alsa-utils-1.2.3':
configure: error: C compiler cannot create executables
See `config.log' for more details

5、移植到arm

【嵌入式】交叉编译 移植 ALSA1.2.2_第7张图片

①、拷贝bin

把 编译出来的 bin 目录中的所有文件拷贝到arm 文件系统的 /bin 目录下

进入 bin目录

cd /home/icedustpan/software/alsa/alsa-utils/bin

【嵌入式】交叉编译 移植 ALSA1.2.2_第8张图片

我的arm文件系统的路径:/home/icedustpan/buildroot-2020.05.1/output/images/rootfs/

拷贝

sudo cp * /home/icedustpan/buildroot-2020.05.1/output/images/rootfs/bin/ -rf

②、拷贝sbin

把 编译出来的 sbin 目录中的所有文件拷贝到arm 文件系统的 /sbin 目录下

进入 sbin目录

cd /home/icedustpan/software/alsa/alsa-utils/sbin

【嵌入式】交叉编译 移植 ALSA1.2.2_第9张图片

我的arm文件系统的路径:/home/icedustpan/buildroot-2020.05.1/output/images/rootfs/

拷贝

sudo cp * /home/icedustpan/buildroot-2020.05.1/output/images/rootfs/sbin -rf

③、拷贝share

把 编译出来的 share 目录中的所有文件拷贝到arm 文件系统的 /usr/share 目录下

进入 share目录

cd /home/icedustpan/software/alsa/alsa-utils/share

【嵌入式】交叉编译 移植 ALSA1.2.2_第10张图片
我的arm文件系统的路径:/home/icedustpan/buildroot-2020.05.1/output/images/rootfs/

拷贝

sudo cp * /home/icedustpan/buildroot-2020.05.1/output/images/rootfs/usr/share -rf

五、配置环境

sudo vi etc/profile

这个是我们之前拷贝的 alsa.conf 的路径

/usr/local/alsa/alsa.conf

在最下面加入

export ALSA_CONFIG_PATH=/usr/local/alsa/alsa.conf

你可能感兴趣的:(嵌入式开发笔记,linux,嵌入式,arm,alsa,aplay)