2010-12-22 95 views
4

我正在嘗試再次爲iOS和iOS SDK 4.2編譯libpq for arm和i386。使用iOS SDK 4.2編譯libpq

我去年做了SDK3.x沒有任何問題。

現在,當我想用​​兩個文件創建脂肪的二進制文件,我得到這個錯誤:

specifed architecture type (arm) for file (/Users/montx/mylibs_sdk42/libpq.arm) does not match its cputype (7) and cpusubtype (3) (should be cputype (12) and cpusubtype (0)) 

我再編譯,因爲我的編譯後的文件不符合最新的iOS4工作.2

Detected an attempt to call a symbol in system libraries that is not present on the iPhone: 
fcntl$UNIX2003 called from function pg_set_noblock in image GlobalScan. 
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first. 

謝謝!

以下是完整的腳本:

#!/bin/bash 

DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 
SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 

rm -rf /Users/montx/mylibs_sdk42 
mkdir /Users/montx/mylibs_sdk42 #Store there compiled libs 
make clean 

#Build ARM library 
./configure --host=arm-apple-darwin --without-readline --disable-ipv6 CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/" CFLAGS="$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT" CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" LD=$DEVROOT/usr/bin/ld 
make -C src/interfaces/libpq 
cp /Users/montx/Downloads/postgresql-8.4.1/src/interfaces/libpq/libpq.a /Users/montx/mylibs_sdk42/libpq.arm 


#Build ARM library 
./configure --host=arm-apple-darwin --without-readline --disable-ipv6 CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/" CFLAGS="$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT" CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" LD=$DEVROOT/usr/bin/ld 



#Then build i386 library ==> the simulator is 32bits 


CFLAGS="$(OTHER_CFLAGS) -mmacosx-version-min=10.5" 
LDFLAGS="$(OTHER_LDFLAGS) -mmacosx-version-min=10.5" 

make clean && ./configure CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" && make -C src/interfaces/libpq 


cp src/interfaces/libpq/libpq.a /Users/montx/mylibs_sdk42/libpq.i386 

#Then make fat binary 
$DEVROOT/usr/bin/lipo -arch armv6 /Users/montx/mylibs_sdk42/libpq.arm -arch i386 /Users/montx/mylibs_sdk42/libpq.i386 -create -output /Users/montx/mylibs_sdk42/libpq 

回答

0

這對我的作品的ARM庫,但我用gcc 4.2和我針對的ARMv7

DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 
SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 
./configure --host=arm-apple-darwin --without-readline --disable-ipv6 \ 
    CC="$DEVROOT/usr/bin/gcc" \ 
    CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ \ 
      -I$SDKROOT/usr/include/" \ 
    CFLAGS="$CPPFLAGS -arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT" \ 
    CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" \ 
    LD=$DEVROOT/usr/bin/ld 
make -C src/interfaces/libpq 
cp src/interfaces/libpq/libpq.a lib/libpq.arm 

我的舊腳本的儘管模擬器不再工作,它仍然可以再次正常工作iOS 3.2。

DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer 
SDKROOT=$DEVROOT/SDKs/iPhoneSimulator4.2.sdk 
$ROOT_DIR/configure --host=i386-apple-darwin \ 
    CC="$DEVROOT/usr/bin/gcc" \ 
    CPPFLAGS="-I$SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/ \ 
      -I$SDKROOT/usr/include/ -mmacosx-version-min=10.5" \ 
    CFLAGS="$CPPFLAGS -arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT \ 
      -mmacosx-version-min=10.5" \ 
    CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" \ 
    LD=$DEVROOT/usr/bin/ld 

make -C $ROOT_DIR/src/interfaces/libpq 

更新

下面是完整的腳本。將bash腳本放在postgres目錄中並構建。在你的項目中包含$ POSTGRESDIR/src/include和$ POSTGRESDIR/src/interfaces/libpq來獲取必要的頭文件。注意這適用於Postgres 8.未在Postgres 9上測試它。

#!/bin/bash 
set -e 

if [ -d "./lib" ] 
then 
    echo "Existing libs deleted" 
    rm -rf lib/* 
else 
    echo "Generating output directory" 
    mkdir lib 
fi 

if [ -e "./src/Makefile.global" ] 
then 
    make -C ./src/interfaces/libpq distclean 
fi 

chmod u+x ./configure 

#Build i386 library 
DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer 
SDKROOT=$DEVROOT/SDKs/iPhoneSimulator4.2.sdk 
./configure --host=i386-apple-darwin --without-readline --disable-ipv6 \ 
    CC="$DEVROOT/usr/bin/gcc-4.2" \ 
    CPPFLAGS="-I$SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/ -I$SDKROOT/usr/include/ -mmacosx-version-min=10.5" \ 
    CFLAGS="$CPPFLAGS -arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -mmacosx-version-min=10.5" \ 
    CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" \ 
    LD=$DEVROOT/usr/bin/ld 

make -C ./src/interfaces/libpq 
cp ./src/interfaces/libpq/libpq.a lib/libpq.i386 

#Build ARM library 
make -C ./src/interfaces/libpq distclean 

DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 
SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 
./configure --host=arm-apple-darwin --without-readline --disable-ipv6 \ 
    CC="$DEVROOT/usr/bin/gcc-4.2" \ 
    CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$SDKROOT/usr/include/" \ 
    CFLAGS="$CPPFLAGS -arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT" \ 
    CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS" \ 
    LD=$DEVROOT/usr/bin/ld 
make -C ./src/interfaces/libpq 
cp ./src/interfaces/libpq/libpq.a lib/libpq.arm