在centos+openwrt 15.05.01下编译owntone
Openwrt中如何单独编译某一个模块:
make package/owntone/download #- download the soures of example
make package/owntone/prepare #- extract the sources, apply patches and download if necessary
make package/owntone/clean
1.安装owntone依赖:
sudo apt-get install \
build-essential git autotools-dev autoconf automake libtool gettext gawk \
gperf bison flex libconfuse-dev libunistring-dev libsqlite3-dev \
libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavutil-dev \
libasound2-dev libxml2-dev libgcrypt20-dev libavahi-client-dev zlib1g-dev \
libevent-dev libplist-dev libsodium-dev libjson-c-dev libwebsockets-dev \
libcurl4-openssl-dev libprotobuf-c-dev
2.下载owntone源码
下载
https://github.com/owntone/owntone-openwrt/tree/master/owntone
放到package目录下。里面的代码不是最新,要修改makefile:
PKG_SOURCE:=(PKG_NAME)-(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://github.com/owntone/owntone-server/releases/download/(PKG_VERSION)/
PKG_HASH:=98538566a993638ec569fc44ea2c7a7fcb5dd925c47b84b64ac2d63fc8b056b8
修改 package/owntone/Makefile 文件,
将 -std=c99 选项添加到 TARGET_CFLAGS 变量中。
找到 TARGET_CFLAGS +=(FPIC) 这一行,并在其前面添加以下代码:
TARGET_CFLAGS += -std=c99
修改后的 Makefile 文件应该如下所示:
TARGET_CFLAGS += -std=c99
TARGET_CFLAGS += $(FPIC)
3.在make menuconfig,在sound里面选择owntone
4.开始编译
“` make -j1 V=s package/owntone/compile #- compile example, prepare and download if necessary “`
先尝试编译owntone,如果没有问题,
接下来开始编译整个工程make -j1 V=s
5.除错。编译过程中会出现各种错误
File "./configure", line 992, in <module>
configure_node(output)
File "./configure", line 530, in configure_node
o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]
IndexError: tuple index out of range
Makefile:72: recipe for target '/root/mt7628-wireless-audio/wireless-music/build_dir/host/node-v0.12.7/.configured' failed
解决方案:
您在 Ubuntu 18.04 上编译 MT7628 无线音频项目时遇到的错误,源于 Node.js v0.12.7 的 configure 脚本中使用了 gcc -dumpversion 来获取 GCC 的版本号。然而,从 GCC 7 开始,-dumpversion 默认只返回主版本号(例如 "7"),而不包括次版本号(例如 "7.5")。这导致脚本在解析版本号时出现 IndexError: tuple index out of range 的错误。
为了解决此问题,您可以修改 configure 脚本中的相关代码,将 -dumpversion 替换为 -dumpfullversion,后者会返回完整的版本号。
请按照以下步骤操作:
定位并编辑 configure 脚本:
在您的项目目录中,找到并打开 configure 脚本。
查找以下代码行:
proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE)
将其修改为:
proc = subprocess.Popen(CC.split() + ['-dumpfullversion'], stdout=subprocess.PIPE)
这样,脚本将使用 gcc -dumpfullversion 来获取完整的版本号。
在编译openwrt时遇到了如下错误,
checking for CONFUSE... no
configure: error: Package requirements (libconfuse >= 3.0) were not met:
Requested 'libconfuse >= 3.0' but version of confuse is 2.7
Consider adjusting the PKG_CONFIG_PATH environment variable if you
你完全可以在 保持目录结构不变的情况下修改 Makefile 来升级版本,这是最直接的方法。
Step 1:
编辑你现有的 feeds/packages/libs/confuse/Makefile:
PKG_VERSION:=3.0
PKG_SOURCE:=(PKG_NAME)-(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://github.com/libconfuse/releases/download/v$(PKG_VERSION)/
PKG_MD5SUM:=c534b51a2118ed57031dc548032304a3
Step 2:
清除旧缓存
rm -rf dl/confuse*
make package/confuse/clean
Step 3:
获取源码并编译
make package/confuse/download V=s
make package/confuse/prepare V=s
make package/confuse/compile V=s
checking for LIBEVENT... no
configure: error: Package requirements (libevent >= 2.1.4) were not met:
Requested 'libevent >= 2.1.4' but version of libevent is 2.0.22-stable
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Step 1: 下载
https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz
修改makefile:
vim feeds/packages/libs/libevent/Makefile
PKG_NAME:=libevent
PKG_VERSION:=2.1.10
PKG_RELEASE:=1
PKG_BUILD_DIR:=(BUILD_DIR)/libevent-(PKG_VERSION)-stable
PKG_SOURCE:=libevent-(PKG_VERSION)-stable.tar.gz
PKG_SOURCE_URL:=https://github.com/libevent/libevent/releases/download/release-(PKG_VERSION)-stable/
PKG_MD5SUM:=999caf86f52943af2363bc8077f00167
PKG_MAINTAINER:=Steven Barth <[email protected]>
Step 2: 清除旧缓存
make package/libevent/clean
Step 3: 获取源码并编译
make package/libevent/download V=s
make package/libevent/prepare V=s
make package/libevent/compile V=s
如果还不行,修改 owntone 的 Makefile
将 +libevent2 改为 +libevent:
- DEPENDS:=+libevent2 +libdaemon +confuse +alsa-lib +libffmpeg-full \
+ DEPENDS:=+libevent +libdaemon +confuse +alsa-lib +libffmpeg-full \
将 package/libs/libevent2 升级为 libevent 2.1.10,以满足 owntone 对 libevent >= 2.1.4 的依赖,同时保持 libevent2 这个名字不变,确保依赖链兼容。
修改 package/libs/libevent2/Makefile 的方法
你当前的 Makefile 很完整,只需要以下几个关键改动:
步骤一:更新版本和下载地址
PKG_VERSION:=2.1.10
PKG_SOURCE:=libevent-(PKG_VERSION)-stable.tar.gz
PKG_SOURCE_URL:=https://github.com/libevent/libevent/releases/download/release-(PKG_VERSION)-stable/
PKG_MD5SUM:=999caf86f52943af2363bc8077f00167
PKG_BUILD_DIR:=(BUILD_DIR)/libevent-(PKG_VERSION)-stable
步骤二:修正 install 段
libevent-2.1.10 的 so 文件后缀从 libevent_core-2.0.so.X 变为 libevent_core-2.1.so.X,因此你的 install 部分需要支持 2.1:
修改这几段安装逻辑(加星号表示要修改):
define Package/libevent2/install
(INSTALL_DIR)(1)/usr/lib
(CP)(PKG_INSTALL_DIR)/usr/lib/libevent-2.1.so.* (1)/usr/lib/ # ★ 修改这里的版本号
endef
define Package/libevent2-core/install(INSTALL_DIR) (1)/usr/lib(CP) (PKG_INSTALL_DIR)/usr/lib/libevent_core-2.1.so.*(1)/usr/lib/ # ★ 修改这里
endef
define Package/libevent2-extra/install
(INSTALL_DIR)(1)/usr/lib
(CP)(PKG_INSTALL_DIR)/usr/lib/libevent_extra-2.1.so.* (1)/usr/lib/ # ★
endef
define Package/libevent2-openssl/install(INSTALL_DIR) (1)/usr/lib(CP) (PKG_INSTALL_DIR)/usr/lib/libevent_openssl-2.1.so.*(1)/usr/lib/ # ★
endef
define Package/libevent2-pthreads/install
(INSTALL_DIR)(1)/usr/lib
(CP)(PKG_INSTALL_DIR)/usr/lib/libevent_pthreads-2.1.so.* $(1)/usr/lib/ # ★
endef
修改完毕后,强烈建议清理并重新构建:
make package/libevent2/clean
rm -rf build_dir/target-*/libevent-*
make package/libevent2/download V=s
make package/libevent2/compile V=s
确认 .pc 文件:
cat staging_dir/target-*/usr/lib/pkgconfig/libevent.pc | grep Version
应该输出:Version: 2.1.10
通过 OpenWrt 的 feed 系统将 ffmpeg 更新到 4.4 或更高版本,手动将新版 FFmpeg 添加到 feed 中(推荐)
你可以从较新 OpenWrt(如 22.03)分支中复制 ffmpeg 4.4 的 Makefile 和相关文件,替换你本地 feed 中的旧版本:
步骤如下:
第一步:备份当前旧版本
mv feeds/packages/multimedia/ffmpeg feeds/packages/multimedia/ffmpeg.old
第二步:从 GitHub 上拉取新版本的 feed
以 OpenWrt 22.03 分支(ffmpeg 4.4)为例:
git clone https://github.com/openwrt/packages.git -b openwrt-22.03 openwrt-packages-22.03
git checkout a68e9db8d4c3a29c86261cd6bb1933fab1cc3a35
commit a68e9db8d4c3a29c86261cd6bb1933fab1cc3a35 (HEAD)
Author: Josef Schlehofer <[email protected]>
Date: Sat Jan 29 11:34:56 2022 +0100
ffmpeg: update to version 4.3.3
Signed-off-by: Josef Schlehofer <[email protected]>
cp -r openwrt-packages-22.03/multimedia/ffmpeg feeds/packages/multimedia/
你也可以只复制必要文件:
cp openwrt-packages-22.03/multimedia/ffmpeg/Makefile feeds/packages/multimedia/ffmpeg/
cp -r openwrt-packages-22.03/multimedia/ffmpeg/patches feeds/packages/multimedia/ffmpeg/
cp -r openwrt-packages-22.03/multimedia/ffmpeg/files feeds/packages/multimedia/ffmpeg/
第三步:更新 feed 和 make
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig # 确保 libffmpeg-full 被选中
make package/ffmpeg/clean
make package/ffmpeg/compile V=s
libavutil/libm.h
+/* Disable MIPS optimized libm due to toolchain incompatibility */
+#if 0
+#if HAVE_MIPSFPU && HAVE_INLINE_ASM
+#include "libavutil/mips/libm_mips.h"
+#endif
+#endif
更新libcurl
git clone https://github.com/openwrt/packages.git -b openwrt-22.03 openwrt-packages-22.03
git checkout a68e9db8d4c3a29c86261cd6bb1933fab1cc3a35
把package下面的curl文件复制到openwrt 15.05那边,修改makefile取消对ssl的支持
make package/curl/clean
make package/curl/compile V=s
patch文件
fast_copy(int fd_dst, int fd_src)
{
// Here we use kernel-space copying for performance reasons
#if defined(__APPLE__)
return fcopyfile(fd_src, fd_dst, 0, COPYFILE_ALL);
#else
struct stat fileinfo = { 0 };
ssize_t bytes_copied;
fstat(fd_src, &fileinfo);
bytes_copied = copy_file_range(fd_src, NULL, fd_dst, NULL, fileinfo.st_size, 0);
if (bytes_copied < 0 || bytes_copied != fileinfo.st_size)
return -1;
return 0;
#endif
}
outputs/airplay.c: In function 'chacha_open':
outputs/airplay.c:619:29: error: 'GCRY_CIPHER_CHACHA20' undeclared (first use in this function)
if (gcry_cipher_open(&hd, GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_POLY1305, 0) != GPG_ERR_NO_ERROR)
^
outputs/airplay.c:619:29: note: each undeclared identifier is reported only once for each function it appears in
outputs/airplay.c:619:51: error: 'GCRY_CIPHER_MODE_POLY1305' undeclared (first use in this function)
if (gcry_cipher_open(&hd, GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_POLY1305, 0) != GPG_ERR_NO_ERROR)
^
make[7]: *** [outputs/airplay.o] Error 1
解决方案一:升级 libgcrypt
找到你 OpenWrt 源码里的 package/feeds/packages/libgcrypt/Makefile
把版本号改为 1.8.x 或 1.9.x,比如:
PKG_VERSION:=1.8.8
PKG_SOURCE:=libgcrypt-(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://gnupg.org/ftp/gcrypt/libgcrypt/
PKG_VERSION:=1.8.8
PKG_SOURCE:=libgcrypt-(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://gnupg.org/ftp/gcrypt/libgcrypt/
PKG_MD5SUM:=4ada2c473f9ae5aff41dd9d08a4a7727
删除旧版本的 build_dir:
make package/libgcrypt/clean
重新编译 libgcrypt:
make package/libgcrypt/compile V=s
确认 staging_dir/target-*/usr/include/gcrypt.h 中有这两个宏:
#define GCRY_CIPHER_CHACHA20 ...
#define GCRY_CIPHER_MODE_POLY1305 ...
再编译 owntone。
checking for GPG Error - version >= 1.25... no
configure: error: libgpg-error is needed.
See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .
make[3]: *** [/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/libgcrypt-1.8.8/.configured_yyyyyyyy] Error 1
make[3]: Leaving directory `/root/wireless-music/feeds/packages/libs/libgcrypt'
make[2]: *** [package/feeds/packages/libgcrypt/compile] Error 2
./package/feeds/packages/libgpg-error
打开makefile
PKG_NAME:=libgpg-error
PKG_VERSION:=1.43
PKG_RELEASE:=1
PKG_SOURCE:=(PKG_NAME)-(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.gnupg.org/ftp/gcrypt/libgpg-error
PKG_MD5SUM:=38be4a4b038c0f36c101d81d95cd3ada
CC outputs/alsa.o
outputs/alsa.c: In function 'pcm_configure':
outputs/alsa.c:634:3: warning: implicit declaration of function 'snd_pcm_sw_params_set_tstamp_type' [-Wimplicit-function-declaration]
ret = snd_pcm_sw_params_set_tstamp_type(hdl, sw_params, SND_PCM_TSTAMP_TYPE_MONOTONIC);
^
outputs/alsa.c:634:59: error: 'SND_PCM_TSTAMP_TYPE_MONOTONIC' undeclared (first use in this function)
ret = snd_pcm_sw_params_set_tstamp_type(hdl, sw_params, SND_PCM_TSTAMP_TYPE_MONOTONIC);
^
outputs/alsa.c:634:59: note: each undeclared identifier is reported only once for each function it appears in
make[7]: *** [outputs/alsa.o] Error 1
make[7]: Leaving directory `/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/owntone-28.12/src'
make[6]: *** [all] Error 2
make[6]: Leaving directory `/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/owntone-28.12/src'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/owntone-28.12'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/owntone-28.12'
make[3]: *** [/root/wireless-music/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/owntone-28.12/.built] Error 2
make[3]: Leaving directory `/root/wireless-music/package/owntone'
make[2]: *** [package/owntone/compile] Error 2
make[2]: Leaving directory `/root/wireless-music'
make[1]: *** [/root/wireless-music/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/root/wireless-music'
make: *** [world] Error 2
feeds/packages/libs/alsa-lib/Makefile
PKG_NAME:=alsa-lib
PKG_VERSION:=1.1.9
PKG_RELEASE:=1
PKG_SOURCE:=(PKG_NAME)-(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.alsa-project.org/pub/lib/ \
http://alsa.cybermirror.org/lib/
PKG_MD5SUM:=e6d429dbdcfaa0f034d907fa6dc3735e
PKG_MAINTAINER:=Ted Hess <[email protected]>