aubio 可以交叉编译 iPhone/Android/ARM 吗?

发布于 2024-11-25 20:15:54 字数 1435 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

朦胧时间 2024-12-02 20:15:54

尝试使用最新的 git:

$ git clone git://git.aubio.org/git/aubio
$ cd aubio/
$ ./waf configure build --with-target-platform ios

Try using the latest git:

$ git clone git://git.aubio.org/git/aubio
$ cd aubio/
$ ./waf configure build --with-target-platform ios
哥,最终变帅啦 2024-12-02 20:15:54

我已经成功地交叉编译了它,没有错误。我还没有测试该库本身,但示例可执行文件似乎可以工作,所以这是一个好兆头!

我整理的脚本(很大程度上要感谢 此链接)应该适用于许多使用 Autotools 的其他项目(例如 Aubio 的依赖项)。

请注意,libsndfilelibsamplerate 都需要补丁才能成功交叉编译,我确信这很丑陋,但它确实有效。

要使用它,请根据您的系统修改脚本(我希望应该非常简单),下载所有依赖项(在最后的 build xxxxx 行中列出,您的版本可能会有所不同)与脚本相同的目录并运行不带参数的脚本。最后,所有内容都应该位于 $SYS_ROOT 目录中。

好了,主菜如下:

#!/bin/bash

# Taken and improved from :
# http://cmumobileapps.com/2011/08/31/compiling-open-source-libraries-with-android-ndk-part-2

# The designation for the host, usually "linux-x86" for standard linuxes, and
# "darwin-x86" for OSX.
HOST="linux-x86"

# The target architecture. Here we're compiling for ARM using GCC 4.7 and
# platform version 14.
TARGET_ARCH="arm"
TARGET_HOST="arm-eabi"
TARGET_TOOLCHAIN="arm-linux-androideabi"
TARGET_GCC_VERSION="4.7"
TARGET_NDK_VERSION="14"

# Add the toolchain to the path to be able to use the ARM compiler.
export PATH="$ANDROID_NDK/toolchains/$TARGET_TOOLCHAIN-$TARGET_GCC_VERSION/prebuilt/$HOST/bin:$PATH"

# Where to find the platform-specific files?
export PLATFORM="$ANDROID_NDK/platforms/android-$TARGET_NDK_VERSION/arch-$TARGET_ARCH/"

# Where to copy the platform-specific files?
# Will be used later as the target system root for cross-compilation.
export SYS_ROOT="`pwd`/sysroot/"

# Executable names for the compilation toolchain
export CC="$TARGET_TOOLCHAIN-gcc --sysroot=$SYS_ROOT"
export CXX="$TARGET_TOOLCHAIN-g++ --sysroot=$SYS_ROOT"
export CPP="$TARGET_TOOLCHAIN-cpp --sysroot=$SYS_ROOT"
export LD="$TARGET_TOOLCHAIN-ld"
export AR="$TARGET_TOOLCHAIN-ar"
export RANLIB="$TARGET_TOOLCHAIN-ranlib"
export STRIP="$TARGET_TOOLCHAIN-strip"

# Add the STLPort library to the search path (needed for C++ files)
export CXXFLAGS="-I$ANDROID_NDK/sources/cxx-stl/stlport/stlport/"
export LDFLAGS="-L$ANDROID_NDK/sources/cxx-stl/stlport/libs/armeabi/ -lstlport_static"

# Where to install the cross-compiled packages?
# When running `make install`, all the files (executables, libraries,
# documentation,...) will be in this directory.
export INSTALL_DIR="$SYS_ROOT/usr/"

# Where will pkg-config look for information about installed packages?
export PKG_CONFIG_LIBDIR="$SYS_ROOT/usr/lib/pkgconfig/"

#################
# Configuration #
#################

# If the sysroot doesn't exist, create it and copy all the files from the NDK
# distribution.
if [[ ! -e "$SYS_ROOT" ]]; then
  echo "Creating sysroot [$SYS_ROOT]"
  cp -Rf "$PLATFORM" "$SYS_ROOT" || exit 2
fi

# If it doesn't exist, create the installation directory.
if [[ ! -e "$INSTALL_DIR" ]]; then
  echo "Creating installation directory [$INSTALL_DIR]"
  mkdir -p $INSTALL_DIR || exit 3
fi

###############
# Compilation #
###############

build() {
  # Change directory to the package directory (in argument)
  echo "Building $1"
  pushd $1

  # Clean things up (optional)
  make clean 1>/dev/null 2>&1

  # Configure the package
  ./configure --host=$TARGET_HOST LIBS="-lc -lgcc" --prefix=$INSTALL_DIR || exit 1

  # Compile
  make || exit 1

  # Install in $INSTALL_DIR
  make install || exit 1

  # Return to the original directory
  popd
}

# Build all things
build libogg-1.3.0
build libvorbis-1.3.3
build flac-1.2.1
build libsndfile-1.0.25-patch
build libsamplerate-0.1.8-patch
build fftw-3.3.3
build aubio-0.3.2

libsndfile patch

--- libsndfile-1.0.25/programs/sndfile-play.c   2012-12-31 17:03:34.289908113 +0100
+++ libsndfile-1.0.25-patch/programs/sndfile-play.c 2012-12-31 17:04:05.326412364 +0100
@@ -55,7 +55,7 @@
 #if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
    #include    <fcntl.h>
    #include    <sys/ioctl.h>
-   #include    <sys/soundcard.h>
+   #include    <linux/soundcard.h>

 #elif (defined (__MACH__) && defined (__APPLE__))
    #include <Carbon.h>
--- libsndfile-1.0.25/src/sndfile.c 2012-12-31 17:03:34.343241171 +0100
+++ libsndfile-1.0.25-patch/src/sndfile.c   2013-01-01 18:53:37.436544846 +0100
@@ -309,7 +309,7 @@
 {  SF_PRIVATE  *psf ;

    /* Ultimate sanity check. */
-   assert (sizeof (sf_count_t) == 8) ;
+   /* assert (sizeof (sf_count_t) == 8) ; */

    if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL)
    {   sf_errno = SFE_MALLOC_FAILED ;

libsamplerate patch

--- libsamplerate-0.1.8/examples/audio_out.c    2011-07-13 01:57:31.000000000 +0200
+++ libsamplerate-0.1.8-patch/examples/audio_out.c  2013-01-01 17:24:58.257526888 +0100
@@ -44,7 +44,7 @@

 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <sys/soundcard.h>
+#include <linux/soundcard.h>

 #define    LINUX_MAGIC     MAKE_MAGIC ('L', 'i', 'n', 'u', 'x', 'O', 'S', 'S')

I've succeeded in cross-compiling it without errors. I haven't tested the library itself, but the example executables seem to work, so that's a good sign!

The script I've put together (largely thanks to the invaluable information in this link) should work for a lot of other projects using Autotools (like Aubio's dependencies).

Note that both libsndfile and libsamplerate need a patch to cross-compile successfully, which I'm sure is ugly, but it works.

To use it, modify the script according to your system (should be pretty straightforward, I hope), download all the dependencies (listed in the build xxxxx lines at the end, your versions may vary) in the same directory as the script and run the script without arguments. At the end, everything should be inside the $SYS_ROOT directory.

Okay, the main dish is below :

#!/bin/bash

# Taken and improved from :
# http://cmumobileapps.com/2011/08/31/compiling-open-source-libraries-with-android-ndk-part-2

# The designation for the host, usually "linux-x86" for standard linuxes, and
# "darwin-x86" for OSX.
HOST="linux-x86"

# The target architecture. Here we're compiling for ARM using GCC 4.7 and
# platform version 14.
TARGET_ARCH="arm"
TARGET_HOST="arm-eabi"
TARGET_TOOLCHAIN="arm-linux-androideabi"
TARGET_GCC_VERSION="4.7"
TARGET_NDK_VERSION="14"

# Add the toolchain to the path to be able to use the ARM compiler.
export PATH="$ANDROID_NDK/toolchains/$TARGET_TOOLCHAIN-$TARGET_GCC_VERSION/prebuilt/$HOST/bin:$PATH"

# Where to find the platform-specific files?
export PLATFORM="$ANDROID_NDK/platforms/android-$TARGET_NDK_VERSION/arch-$TARGET_ARCH/"

# Where to copy the platform-specific files?
# Will be used later as the target system root for cross-compilation.
export SYS_ROOT="`pwd`/sysroot/"

# Executable names for the compilation toolchain
export CC="$TARGET_TOOLCHAIN-gcc --sysroot=$SYS_ROOT"
export CXX="$TARGET_TOOLCHAIN-g++ --sysroot=$SYS_ROOT"
export CPP="$TARGET_TOOLCHAIN-cpp --sysroot=$SYS_ROOT"
export LD="$TARGET_TOOLCHAIN-ld"
export AR="$TARGET_TOOLCHAIN-ar"
export RANLIB="$TARGET_TOOLCHAIN-ranlib"
export STRIP="$TARGET_TOOLCHAIN-strip"

# Add the STLPort library to the search path (needed for C++ files)
export CXXFLAGS="-I$ANDROID_NDK/sources/cxx-stl/stlport/stlport/"
export LDFLAGS="-L$ANDROID_NDK/sources/cxx-stl/stlport/libs/armeabi/ -lstlport_static"

# Where to install the cross-compiled packages?
# When running `make install`, all the files (executables, libraries,
# documentation,...) will be in this directory.
export INSTALL_DIR="$SYS_ROOT/usr/"

# Where will pkg-config look for information about installed packages?
export PKG_CONFIG_LIBDIR="$SYS_ROOT/usr/lib/pkgconfig/"

#################
# Configuration #
#################

# If the sysroot doesn't exist, create it and copy all the files from the NDK
# distribution.
if [[ ! -e "$SYS_ROOT" ]]; then
  echo "Creating sysroot [$SYS_ROOT]"
  cp -Rf "$PLATFORM" "$SYS_ROOT" || exit 2
fi

# If it doesn't exist, create the installation directory.
if [[ ! -e "$INSTALL_DIR" ]]; then
  echo "Creating installation directory [$INSTALL_DIR]"
  mkdir -p $INSTALL_DIR || exit 3
fi

###############
# Compilation #
###############

build() {
  # Change directory to the package directory (in argument)
  echo "Building $1"
  pushd $1

  # Clean things up (optional)
  make clean 1>/dev/null 2>&1

  # Configure the package
  ./configure --host=$TARGET_HOST LIBS="-lc -lgcc" --prefix=$INSTALL_DIR || exit 1

  # Compile
  make || exit 1

  # Install in $INSTALL_DIR
  make install || exit 1

  # Return to the original directory
  popd
}

# Build all things
build libogg-1.3.0
build libvorbis-1.3.3
build flac-1.2.1
build libsndfile-1.0.25-patch
build libsamplerate-0.1.8-patch
build fftw-3.3.3
build aubio-0.3.2

libsndfile patch

--- libsndfile-1.0.25/programs/sndfile-play.c   2012-12-31 17:03:34.289908113 +0100
+++ libsndfile-1.0.25-patch/programs/sndfile-play.c 2012-12-31 17:04:05.326412364 +0100
@@ -55,7 +55,7 @@
 #if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
    #include    <fcntl.h>
    #include    <sys/ioctl.h>
-   #include    <sys/soundcard.h>
+   #include    <linux/soundcard.h>

 #elif (defined (__MACH__) && defined (__APPLE__))
    #include <Carbon.h>
--- libsndfile-1.0.25/src/sndfile.c 2012-12-31 17:03:34.343241171 +0100
+++ libsndfile-1.0.25-patch/src/sndfile.c   2013-01-01 18:53:37.436544846 +0100
@@ -309,7 +309,7 @@
 {  SF_PRIVATE  *psf ;

    /* Ultimate sanity check. */
-   assert (sizeof (sf_count_t) == 8) ;
+   /* assert (sizeof (sf_count_t) == 8) ; */

    if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL)
    {   sf_errno = SFE_MALLOC_FAILED ;

libsamplerate patch

--- libsamplerate-0.1.8/examples/audio_out.c    2011-07-13 01:57:31.000000000 +0200
+++ libsamplerate-0.1.8-patch/examples/audio_out.c  2013-01-01 17:24:58.257526888 +0100
@@ -44,7 +44,7 @@

 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <sys/soundcard.h>
+#include <linux/soundcard.h>

 #define    LINUX_MAGIC     MAKE_MAGIC ('L', 'i', 'n', 'u', 'x', 'O', 'S', 'S')
月光色 2024-12-02 20:15:54

这是一个对我有用的构建脚本:

#! /bin/sh

"""
build the toold chain home with:
build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=../android-9-toolchain
"""

NDK_HOME=~/dev/SDKs/android-9-toolchain
set -x
set -e
export CC=$NDK_HOME/bin/arm-linux-androideabi-gcc
export CFLAGS=-I$NDK_HOME/include
export LDFLAGS="-L$NDK_HOME/lib"
export AR=$NDK_HOME/bin/arm-linux-androideabi-ar

./waf distclean
./waf configure --with-target-platform android --disable-jack
./waf build --verbose
./waf install --destdir dist-android

它将默认为工具链/gcc 版本 4.6,我将其更改为 4.9,因为这是我拥有的最新版本。
它应该下拉完成编译脚本主要部分所需的库,

由 Aubio 的作者 Paul Brossier 友情提供

Here is a build script that worked for me:

#! /bin/sh

"""
build the toold chain home with:
build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=../android-9-toolchain
"""

NDK_HOME=~/dev/SDKs/android-9-toolchain
set -x
set -e
export CC=$NDK_HOME/bin/arm-linux-androideabi-gcc
export CFLAGS=-I$NDK_HOME/include
export LDFLAGS="-L$NDK_HOME/lib"
export AR=$NDK_HOME/bin/arm-linux-androideabi-ar

./waf distclean
./waf configure --with-target-platform android --disable-jack
./waf build --verbose
./waf install --destdir dist-android

it will default to toolchain / gcc version 4.6, I changed this to 4.9 as that is the latest I have.
it should pull down the libraries it needs to finish compiling

the main part of the script was kindly provided by Paul Brossier author of Aubio

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文