2011-08-28 116 views
6

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

我发现Glen Low's configure instructions,并与一些知情的猜测更新了这些到:

./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" 

这工作,但随后的“让”运行了一段时间,与错误的:

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 

我不太了解所有的架构规范,所以任何帮助实现它的工作都是非常受欢迎的。

回答

0

看起来链接器试图链接到Mac上安装的系统库。这些库都将被编译为i386或x86_64,这在编译iPhone库时不起作用。您需要重新配置链接器以链接到iPhone SDK中的库。

还应该注意的是,您可能需要两次编译库 - 一次是armv6,另一次是armv7。 iPhone 3G和一些较旧的iPod Touch使用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

查找-arch I386在CFLAG并将它更改为: -arch的ARMv6

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

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

+0

有人可以确认这是否工作? –

1

问题在于,mkdefs在构建过程本身被创建后执行。所以如果你为armv6或者armv7构建的话,这个文件就不能在Mac OS X的命令行中执行。我的解决方法是为架构i386(也是iPhone模拟器所需的)构建一个mkdefs,并将它复制到lib/gvpr目录得到这个错误后。确保文件不能被覆盖并重新启动构建。

2

我得到了这个工作。构建脚本在尝试制作可执行文件时最终失败,因为它是为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 
+0

请看看http://stackoverflow.com/questions/10941247/graphviz-for-ios-build-with-xcode-4-3-fails-with-ld-error根据你的答案 –