【发布时间】:2014-01-21 10:51:21
【问题描述】:
基于How can I compile lame as static library...?,我在 macbook pro 上使用此脚本编译了 lame:
mkdir -p build
rm -rf build/* #*/
function build_lame()
{
make distclean
./configure \
CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${SDK}.platform/Developer/SDKs/$SDK$SDK_VERSION.sdk" \
CC="/Applications/Xcode.app/Contents/Developer/usr/bin/gcc -arch $PLATFORM -miphoneos-version-min=7.0" \
--prefix="/Users/$USER/Desktop/$PROJECTNAME" \
--host="arm-apple-darwin9" \
--disable-shared \
--enable-static \
--disable-frontend \
make
cp "$PROJECTNAME/.libs/$PROJECTNAME.a" "build/$PROJECTNAME-$PLATFORM.a"
}
PROJECTNAME=libmp3lame
SDK_VERSION=7.0
SDK="iPhoneSimulator"
PLATFORM="i386"
build_lame
SDK="iPhoneOS"
PLATFORM="armv7"
build_lame
SDK="iPhoneOS"
PLATFORM="armv7s"
build_lame
lipo -create build/$PROJECTNAME-* -output build/$PROJECTNAME.a
然后,我将生成的 libmp3lame.a 添加到 Xcode 5.0.2 中的 iPhone 项目中。在为 iOS 设备构建时,它工作正常。我的问题从为模拟器构建时开始。执行此操作时,我收到以下链接器错误:
Undefined symbols for architecture i386:
"_init_xrpow_core_sse", referenced from:
_init_xrpow_core_init in libmp3lame.a(quantize.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
为什么会出现这个错误以及如何解决?
这是来自 lame 库的quantize.c 的代码 sn-p:
static void
init_xrpow_core_c(gr_info * const cod_info, FLOAT xrpow[576], int upper, FLOAT * sum)
{
// here, the initialization of xrpow is done in normal c code (i've cut that out to keep it small)
}
void
init_xrpow_core_init(lame_internal_flags * const gfc)
{
gfc->init_xrpow_core = init_xrpow_core_c;
#if defined(HAVE_XMMINTRIN_H)
if (gfc->CPU_features.SSE)
gfc->init_xrpow_core = init_xrpow_core_sse;
#endif
#ifndef HAVE_NASM
#ifdef MIN_ARCH_SSE
gfc->init_xrpow_core = init_xrpow_core_sse;
#endif
#endif
}
【问题讨论】:
标签: ios iphone xcode lame i386