我正在尝试将第三方库(如fftw3和sndfile)链接到Xcode3.2中的我的iPhone项目.我通过在项目构建配置下将"Header Search Path"设置为"/ usr/local/include"并将"Other Linker Flags"设置为"-lfftw3 -lsndfile",使其在常规Mac项目中工作.但是,当我尝试使用相同的设置在iPhone项目中构建它时,它给出了"找不到-lfftw3库"和退出代码1错误消息.
苹果在iPhone上不允许这样吗?有办法解决这个问题吗?
我已经修改了IOS 5.0+的Epskampie脚本
和OS X 10.7上使用fftw3.3.3的IOS SDK 6.0和MacOSX SDK 10.8
#!/bin/sh
# build_ios5.sh
# build an arm / i386 / x86_64 lib of fftw3
# make sure to check that all the paths used in this script exist on your system
#
# adopted from:
# http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
# changed by Nickun
# original:
# http://stackoverflow.com/questions/3588904/how-to-link-third-party-libraries-like-fftw3-and-sndfile-to-an-iphone-project-in
# make sure we start out clean
make distclean
# this is the folder where the results of our efforts will end up:
export RESULT_DIR=ios-library
# Select toolchains folder
export XCODE_TOOLCHAINS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
# Select the desired iPhone SDK
export DEVROOT_IOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT_IOS=$DEVROOT_IOS/SDKs/iPhoneOS6.0.sdk
# Select the OSX SDK
export DEVROOT_OSX=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
export SDKROOT_OSX=$DEVROOT_OSX/SDKs/MacOSX10.8.sdk
# ------------------------ armv7---------------------------
# Set up relevant environment variables
export CPPFLAGS="-I$SDKROOT_IOS/usr/include/ -mfpu=neon"
export CFLAGS="$CPPFLAGS -arch armv7 -mfpu=neon -no-cpp-precomp -miphoneos-version-min=5.0 -isysroot $SDKROOT_IOS"
export LD=$XCODE_TOOLCHAINS/usr/bin/ld
export CXX="$XCODE_TOOLCHAINS/usr/bin/clang -x c++ -arch armv7 -std=gnu++11 -stdlib=libc++ -mfpu=neon"
export CC="$XCODE_TOOLCHAINS/usr/bin/clang -x c -arch armv7 -std=gnu99 -mfpu=neon"
export CXXFLAGS="$CFLAGS"
# TODO: add custom flags as necessary for package
# remove '--enable-float' for double precision
# and take a 'libfftw3.a' file instead
./configure --host=arm-apple-darwin --enable-float --enable-neon
make -j2
# Copy the ARM library to a temporary location
mkdir $RESULT_DIR
cp .libs/libfftw3f.a $RESULT_DIR/libfftw3f_armv7.a
# Copy the header file too, just for convenience
cp api/fftw3.h $RESULT_DIR/fftw3.h
# ------------------------ armv7s---------------------------
# Do it all again for i386
make distclean
# Restore default environment variables
unset CPPFLAGS CFLAGS CPP LD CXX LDFLAGS CXXFLAGS
# Set up relevant environment variables
export CPPFLAGS="-I$SDKROOT_IOS/usr/include/ -mfpu=neon"
export CFLAGS="$CPPFLAGS -arch armv7s -mfpu=neon -no-cpp-precomp -miphoneos-version-min=5.0 -isysroot $SDKROOT_IOS"
export LD=$XCODE_TOOLCHAINS/usr/bin/ld
export CXX="$XCODE_TOOLCHAINS/usr/bin/clang -x c++ -arch armv7s -std=gnu++11 -stdlib=libc++ -mfpu=neon"
export CC="$XCODE_TOOLCHAINS/usr/bin/clang -x c -arch armv7s -std=gnu99 -mfpu=neon"
export CXXFLAGS="$CFLAGS"
# TODO: add custom flags as necessary for package
# remove '--enable-float' for double precision
# and take a 'libfftw3.a' file instead
./configure --host=arm-apple-darwin --enable-float --enable-neon
make -j2
# Copy the ARM library to a temporary location
mkdir $RESULT_DIR
cp .libs/libfftw3f.a $RESULT_DIR/libfftw3f_armv7s.a
# ------------------------ i386 ---------------------------
# Do it all again for i386
make distclean
# Restore default environment variables
unset CPPFLAGS CFLAGS CPP LD CXX LDFLAGS CXXFLAGS
export CPPFLAGS="-I$SDKROOT_OSX/usr/include/"
export CFLAGS="$CPPFLAGS -arch i386 -no-cpp-precomp -mmacosx-version-min=10.7 -isysroot $SDKROOT_OSX"
export LD="$XCODE_TOOLCHAINS/usr/bin/ld"
export CXX="$XCODE_TOOLCHAINS/usr/bin/clang -x c++ -arch i386 -std=gnu++11 -stdlib=libc++"
export CC="$XCODE_TOOLCHAINS/usr/bin/clang -x c -arch i386 -std=gnu99"
export CXXFLAGS="$CFLAGS"
# TODO: error checking
./configure --enable-float
make -j2
# Copy the FAT native library to the temporary location
cp .libs/libfftw3f.a $RESULT_DIR/libfftw3f_i386.a
# ------------------------ x86_64 ---------------------------
# Do it all again for x86_64
make distclean
# Restore default environment variables
unset CPPFLAGS CFLAGS CPP LD CXX LDFLAGS CXXFLAGS
export CPPFLAGS="-I$SDKROOT_OSX/usr/include/"
export CFLAGS="$CPPFLAGS -arch x86_64 -no-cpp-precomp -mmacosx-version-min=10.7 -isysroot $SDKROOT_OSX"
export LD="$XCODE_TOOLCHAINS/usr/bin/ld"
export CXX="$XCODE_TOOLCHAINS/usr/bin/clang -x c++ -arch x86_64 -std=gnu++11 -stdlib=libc++"
export CC="$XCODE_TOOLCHAINS/usr/bin/clang -x c -arch x86_64 -std=gnu99"
export CXXFLAGS="$CFLAGS"
# TODO: error checking
./configure --enable-float
make -j2
# Copy the FAT native library to the temporary location
cp .libs/libfftw3f.a $RESULT_DIR/libfftw3f_x86_64.a
# Create fat lib by combining the two versions
lipo -arch armv7 $RESULT_DIR/libfftw3f_armv7.a -arch armv7s $RESULT_DIR/libfftw3f_armv7s.a -arch i386 $RESULT_DIR/libfftw3f_i386.a -arch x86_64 $RESULT_DIR/libfftw3f_x86_64.a -create -output $RESULT_DIR/libfftw3f.a
# Remove intermediate binaries
#rm $RESULT_DIR/libfftw3_armv7.a
#rm $RESULT_DIR/libfftw3_i386.a
#rm $RESULT_DIR/libfftw3_x86_64.a
# Unset used environment variables
unset CPPFLAGS CFLAGS CPP LD LDFLAGS CXX CXXFLAGS
Run Code Online (Sandbox Code Playgroud)
为了编译fftw3以便在iOS项目中使用,我已经改编了这里发布的脚本:http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
与带有iOs SDK 3.2的OS X 10.6上的fftw3.2.2一起使用
#!/bin/sh
# build_iphone.sh
# build an arm / i386 lib of fftw3
# make sure to check that all the paths used in this script exist on your system
#
# adopted from:
# http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
# make sure we start out clean
make distclean
# this is the folder where the results of our efforts will end up:
export RESULT_DIR=ios-library
# Select the desired iPhone SDK
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.2.sdk
# Set up relevant environment variables
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/ -miphoneos-version-min=2.2"
export CFLAGS="$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS"
export CXXFLAGS="$CFLAGS"
# TODO: add custom flags as necessary for package
./configure CC=$DEVROOT/usr/bin/arm-apple-darwin10-gcc-4.0.1 LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin
make -j4
# Copy the ARM library to a temporary location
mkdir $RESULT_DIR
cp .libs/libfftw3.a $RESULT_DIR/libfftw3_arm.a
# Copy the header file too, just for convenience
cp api/fftw3.h ios-library/fftw3.h
# Do it all again for i386
make distclean
# Restore default environment variables
unset CPPFLAGS CFLAGS CPP LDFLAGS CXXFLAGS DEVROOT SDKROOT
export DEVROOT=/Developer
export SDKROOT=$DEVROOT/SDKs/MacOSX10.6.sdk
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.0.1/include/ -I$SDKROOT/usr/include/ -mmacosx-version-min=10.5"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT -arch i386"
export CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS"
export CXXFLAGS="$CFLAGS"
# TODO: error checking
./configure
make -j4
# Copy the native library to the temporary location
cp .libs/libfftw3.a $RESULT_DIR/libfftw3_386.a
# Create fat lib by combining the two versions
lipo -arch arm $RESULT_DIR/libfftw3_arm.a -arch i386 $RESULT_DIR/libfftw3_386.a -create -output $RESULT_DIR/libfftw3.a
# Remove intermediate binaries
rm $RESULT_DIR/libfftw3_arm.a
rm $RESULT_DIR/libfftw3_386.a
# Unset used environment variables
unset CPPFLAGS CFLAGS CPP LDFLAGS CPP CXXFLAGS DEVROOT SDKROOT
Run Code Online (Sandbox Code Playgroud)
从包含fftw3的目录运行此脚本.您需要的文件应该最终在ios-library文件夹中.
| 归档时间: |
|
| 查看次数: |
5419 次 |
| 最近记录: |