Objective c 为iOS构建静态Graphviz库

Objective c 为iOS构建静态Graphviz库,objective-c,ios,ios4,graphviz,Objective C,Ios,Ios4,Graphviz,我正在尝试为Graphviz构建静态库,以便将它们包含在iOS应用程序中,但我无法让它工作。以下是我迄今为止使用graphviz 2.28.0]、Xcode 4.1、OSX 10.7所做的工作,我的目标是iOS模拟器 我发现,并通过一些知情猜测,将这些更新为: ./configure --build=i486-apple-darwin --host=arm-apple-darwin9 --disable-dependency-tracking --enable-shared=no --enabl

我正在尝试为Graphviz构建静态库,以便将它们包含在iOS应用程序中,但我无法让它工作。以下是我迄今为止使用graphviz 2.28.0]、Xcode 4.1、OSX 10.7所做的工作,我的目标是iOS模拟器

我发现,并通过一些知情猜测,将这些更新为:

./configure --build=i486-apple-darwin --host=arm-apple-darwin9 --disable-dependency-tracking --enable-shared=no --enable-static=yes --enable-ltdl-install=no --enable-ltdl=no --enable-swig=no --enable-tcl=no --with-codegens=no --with-fontconfig=no --with-freetype2=no --with-ipsepcola=yes --with-libgd=no --with-quartz=yes --with-visio=yes --with-x=no --with-cgraph=no CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2" CPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -E" CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2" CXXCPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -E" OBJC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2" LD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld" CPPFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -miphoneos-version-min=4.0" CXXCPPFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -miphoneos-version-min=4.0"
这是可行的,但是“make”运行了一段时间,并出现以下错误:

Making all in gvpr
  CCLD   mkdefs
ld: warning: ignoring file mkdefs.o, file was built for armv6 which is not the architecture being linked (i386)
ld: warning: ignoring file /usr/local/lib/libSystem.dylib, missing required architecture i386 in file
ld: warning: symbol dyld_stub_binder not found, normally in libSystem.dylib
Undefined symbols for architecture i386:
  "_exit", referenced from:
      start in crt1.10.6.o
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make[3]: *** [mkdefs] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

我不太了解所有的体系结构规范,因此非常欢迎为使其正常工作提供任何帮助。

链接器似乎正在尝试链接到Mac上安装的系统库。这些库都是为i386或x86_64编译的,在为iPhone编译库时,这是行不通的。您需要重新配置链接器,以链接iPhone SDK中的库

还应该注意,您可能需要编译该库两次—一次编译为armv6,另一次编译为armv7。iphone3g和一些较旧的ipodtouch使用armv6架构,而较新的iPhone使用armv7架构。在编译了两种体系结构下的库之后,您可以使用lipo(在终端中键入“man-lipo”了解更多信息)创建一个包含两种体系结构的静态库。如果你打算使用iPhone/iPad模拟器开发你的应用程序,那么我还建议你编译一次i386,这样你就可以在模拟器上使用你的库。同样,lipo可以创建一个包含所有3种体系结构的静态库

现在GraphViz网站目前似乎无法访问,因此我无法像您那样下载库并运行配置脚本,但我怀疑在运行“make”之前,您应该对配置脚本生成的makefile进行以下更改。根据您要针对的iOS SDK版本以及您机器上的gcc版本,您可能需要调整以下一些更改,以便它们适合您的环境。以下说明适用于armv6。一旦准备好处理该体系结构,就需要更改为armv7构建的设置

查找CC=CC并将其更改为: CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2

在CFLAG中找到-arch i386并将其更改为: -拱臂V6

找到CFLAG并添加到开头!!: -isysroot/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk

查找SHARED_LDFLAGS=-arch i386-dynamiclib并将其更改为:
SHARED_LDFLAGS=-arch armv6-dynamiclib

问题在于mkdefs在创建之后的构建过程中执行。因此,如果您为armv6或armv7构建该文件,则无法在Mac OS X的命令行上执行。我的解决方法是为架构i386构建一个mkdefs(这也是iPhone模拟器所需的),并在出现此错误后将其复制到lib/gvpr目录中。确保文件不能被覆盖,然后重新启动构建。

我已经开始工作了。构建脚本在最后尝试生成可执行文件时失败,因为它是为i386而不是x86或x86_64编译的,但所有库的构建都很好

# For iPhoneOS
export DEV_iOS=/Developer/Platforms/iPhoneOS.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneOS5.0.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch armv7 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/llvm-cpp-4.2
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/llvm-cpp-4.2
export RANLIB=${COMPILER_iOS}/ranlib

./configure --host=arm-apple-darwin11 --disable-dependency-tracking --enable-shared=no --enable-static=yes --enable-ltdl-install=no --enable-ltdl=no --enable-swig=no --enable-tcl=no --with-codegens=no --with-fontconfig=no --with-freetype2=no --with-ipsepcola=yes --with-libgd=no --with-quartz=yes --with-visio=yes --with-x=no --with-cgraph=no
请根据您的回答看一看