На основе Как мне скомпилировать lame как статическую библиотеку...?, я скомпилировал lame с помощью этого скрипта на macbook pro:
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
в проект iPhone в Xcode 5.0.2. При сборке для устройства 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)
Почему возникает эта ошибка и как ее решить?
Вот фрагмент кода из quantize.c
из библиотеки lame:
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
}