Compiling libpq with iOS SDK 4.2

梦想与她 提交于 2019-12-04 11:19:20

This works for me for the arm library but I'm using gcc 4.2 and I'm targeting 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

My old script for the simulator doesn't work anymore though, and it usto work fine again 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

Updated

Here is the complete script. Drop the bash script in the postgres directory and build. In your project include $POSTGRESDIR/src/include and $POSTGRESDIR/src/interfaces/libpq to get the headers necessary. Note this works for Postgres 8. Haven't tested it on 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

There is project "libpq-ios" on github. I used it.

https://github.com/spacialdb/libpq-ios http://devcenter.spacialdb.com/iOS.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!