使用iOS SDK 4.2编译libpq [英] Compiling libpq with iOS SDK 4.2

查看:331
本文介绍了使用iOS SDK 4.2编译libpq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图再次编译libpq的arm和i386与iOS SDK 4.2。



我去年对于SDK3.x没有任何问题。 / p>

现在,当我想创建两个文件的胖二进制文件时,我收到此错误:



<$文件(/Users/montx/mylibs_sdk42/libpq.arm)的指定架构类型(arm)不匹配其cputype(7)和cpusubtype(3)(应为cputype(12))p $ p> 和cpusubtype(0))



我再次编译,因为我的编译文件不能使用最新的iOS4.2

 检测到尝试调用iPhone中不存在的系统库中的符号:
fcntl $ UNIX2003从图像GlobalScan中的函数pg_set_noblock调用。
如果你遇到这个问题在gdb中运行一个模拟器二进制文件,请确保你'首先设置start-with-shell关闭'。

感谢!



脚本:

 #!/ bin / bash 

DEVROOT = / Developer / Platforms / iPhoneOS.platform /开发人员
SDKROOT = $ DEVROOT /软件开发工具包/ iPhoneOS4.2.sdk

室射频/用户/ montx / mylibs_sdk42
的mkdir /用户/ montx / mylibs_sdk42 #Store有编译libs
make clean

#Build ARM库
./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哌-no-CPP-预补偿-isysroot $ SDKROOTCPP =$ DEVROOT的/ usr / bin中/ CPP $ CPPFLAGSLD = $ DEVROOT的/ usr / bin中/ LD
使-C SRC /接口/ libpq的
CP /Users/montx/Downloads/postgresql-8.4.1/src/interfaces/libpq/libpq.a /Users/montx/mylibs_sdk42/libpq.arm


#Build ARM库
./configure --host = arm-apple-darwin --without-readline --disable-ipv6 CC = $ DEVROOT / usr / bin / arm- darwin9-GCC-4.0.1 CPPFLAGS = - I $ SDKROOT / usr / lib目录/ GCC / ARM-苹果darwin9 / 4.0.1 /有/ -I $ SDKROOT / usr / include目录/CFLAGS =$ CPPFLAGS -arch ARMv6的-pipe -no-CPP-预补偿-isysroot $ SDKROOTCPP =DEVROOT $在/ usr /斌/ CPP $ CPPFLAGSLD = $ DEVROOT / USR /斌/ LD



#Then build i386 library ==>模拟器是32位


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


解决方案

但我使用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

我的旧脚本模拟器不工作了, 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



已更新



这是完整的脚本。删除postgres目录中的bash脚本并生成。在您的项目中包含$ POSTGRESDIR / src / include和$ POSTGRESDIR / src / interfaces / libpq以获取标头必需。注意这适用于Postgres 8.没有在Postgres 9上测试它。

 #!/ bin / bash 
set -e

if [-d./lib]
then
echo现有库已删除
rm -rf lib / *
else
echo生成输出目录
mkdir lib
fi

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

chmod u + x ./configure

#Build i386库
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
b $ b make -C ./src/interfaces/libpq
cp ./src/interfaces/libpq/libpq.a lib / libpq.i386

#Build ARM库
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


I'm trying to compile again the libpq for arm and i386 with the iOS SDK 4.2.

I did last year for SDK3.x without any problems.

Now, when I want to create the fat binary file with two files, I'm getting this error:

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))

I'm compiling again because my compiled files doesn't work with the latest 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.

thanks!

Here is the full script:

#!/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

解决方案

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

这篇关于使用iOS SDK 4.2编译libpq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆