问题
I'm trying to compile lame mp3 encoder as static library for iOS. I'd like to support all architectures including i686, armv6, armv7, armv7s and arm64. Here is my build script:
#!/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
So the error looks like this:
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 is my config.log. | tried to remove arm64 from build targets, but script also failed with same error. Google said that I haven't got gcc but I have.. Looking for any suggestion!
回答1:
The problem was solved by adding CPP="*" variable inside configure function. CPP was missed in my env. Edited build script should looks like this:
#!/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
回答2:
From comment to answer.
CPP
is being set to a very odd value for some reason.
You are manually setting CC
on the configure line to a path inside XcodeDefault
.
Try setting CPP
on the configure call to an appropriate cpp
binary inside XcodeDefault
as well.
来源:https://stackoverflow.com/questions/25885483/cant-compile-lame-for-ios