【问题标题】:Can't compile LAME for iOS无法为 iOS 编译 LAME
【发布时间】:2014-09-17 08:13:18
【问题描述】:

我正在尝试将 lame mp3 编码器编译为 iOS 的静态库。我想支持所有架构,包括 i686、armv6、armv7、armv7s 和 arm64。这是我的构建脚本:

#!/bin/bash
DEVELOPER=`xcode-select -print-path`
SDK_VERSION="7.1"
mkdir build
function build_lame()
{
    make distclean
    ./configure \
    CFLAGS="-isysroot ${DEVELOPER}/Platforms/${SDK}.platform/Developer/SDKs/${SDK}${SDK_VERSION}.sdk" \
    CC="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch ${PLATFORM} -miphoneos-version-min=7.0 " \
    --prefix=/Users/mcrute/Desktop/lame \
    --host="arm-apple-darwin9" \
    --disable-shared \
    --enable-static \
    --disable-decoder \
    --disable-frontend

make -j4
cp "libmp3lame/.libs/libmp3lame.a" "build/libmp3lame-${PLATFORM}.a"
}
SDK="iPhoneSimulator"
PLATFORM="i686"
build_lame
SDK="iPhoneOS"
PLATFORM="armv6"
build_lame
PLATFORM="armv7"
build_lame
PLATFORM="armv7s"
build_lame
PLATFORM="arm64"
build_lame
lipo -create build/* -output build/libmp3lame.a

所以错误看起来像这样:

configure: error: in `/Users/ivan/Desktop/lame-3.99.5':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.
cp: libmp3lame/.libs/libmp3lame.a: No such file or directory

Here 是我的 config.log。 |试图从构建目标中删除 arm64,但脚本也因同样的错误而失败。谷歌说我没有 gcc 但我有.. 寻找任何建议!

【问题讨论】:

  • /lib/cpp 对我来说似乎是一条奇怪的路径(特别是考虑到clang 的路径)你知道这个值来自哪里吗? XcodeDefault.xctoolchain 下是否有 cpp 二进制文件?将其设置为CPP 的路径是否可以解决问题?
  • 我尝试添加 env CPP=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp。但它仍然不起作用。
  • 那是正确的道路吗?您将其添加到 configure 调用中?错误有没有改变?
  • 很遗憾没有。我在执行构建脚本之前添加了 CPP env var。但是什么也没发生:(你能不能试着用我的脚本从这里构建源代码:lame.sourceforge.net
  • 所以你没有把它放在configure 行?使用 env var 路由,错误没有改变?你export CPP了吗?将CPP=.... 放在configure 行会改变事情吗?我没有 OS X。

标签: ios makefile lame


【解决方案1】:

通过在配置函数中添加 CPP="*" 变量解决了问题。我的环境中错过了 CPP。编辑后的构建脚本应如下所示:

#!/bin/bash

DEVELOPER=`xcode-select -print-path`

SDK_VERSION="7.1"

mkdir build

function build_lame()
{
    make distclean

    ./configure \
    CPP="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp" \
    CFLAGS="-isysroot ${DEVELOPER}/Platforms/${SDK}.platform/Developer/SDKs/${SDK}${SDK_VERSION}.sdk" \
    CC="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch ${PLATFORM} -miphoneos-version-min=7.0 " \
    --prefix=/Users/ivan/Desktop/lame-3.99.5 \
    --host="arm-apple-darwin9" \
    --disable-shared \
    --enable-static \
    --disable-decoder \
    --disable-frontend

    make -j4
    cp "libmp3lame/.libs/libmp3lame.a" "build/libmp3lame-${PLATFORM}.a"
}

PLATFORM="i686"
SDK="iPhoneSimulator"
build_lame

PLATFORM="armv6"
SDK="iPhoneOS"
build_lame

PLATFORM="armv7"
build_lame

PLATFORM="armv7s"
build_lame

PLATFORM="arm64"
build_lame

lipo -create build/* -output build/libmp3lame.a

【讨论】:

  • 是否有可能将编译后的库公开?
  • 您应该能够使用该脚本自己构建它,只要您编辑--prefix 以指向您正确的蹩脚文件夹。
【解决方案2】:

从评论到回答。

CPP 由于某种原因被设置为一个非常奇怪的值。

您在配置行上手动将CC 设置为XcodeDefault 内的路径。

尝试在配置调用中将CPP 设置为XcodeDefault 内的适当cpp 二进制文件。

【讨论】:

  • 就我而言,一个完全正常的 CPP /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp 未能通过 Xcode 11.3 进行健全性检查。在终端中运行相同的构建脚本可以正常工作。有什么问题?请你看看stackoverflow.com/questions/59350668/…
猜你喜欢
  • 1970-01-01
  • 2014-02-03
  • 2012-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-09
  • 2017-03-20
相关资源
最近更新 更多