Build static Graphviz libraries for iOS

后端 未结 3 607
庸人自扰
庸人自扰 2021-02-06 05:55

I am trying build the static libraries for Graphviz to include them in in an iOS app, but I can\'t get it to work. Here\'s what I have done so far, using graphviz 2.28.0], Xcode

相关标签:
3条回答
  • 2021-02-06 06:36

    I got this working. The build script fails at the end when it tried to make an executable since it's compiled for i386 instead of x86 or x86_64 but all the libraries build just fine.

    # 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 讨论(0)
  • 2021-02-06 06:37

    It appears that the linker is trying to link to the system libraries installed on your Mac. Those libraries are all going to be compiled for i386 or x86_64 which isn't going to work when compiling libraries for iPhone. You'll need to reconfigure the linker to link against the libraries that come in the iPhone SDK.

    It should also be noted that you will probably have to compile the library twice - once as armv6 and again as armv7. iPhone 3G and some of the older iPod Touches use the armv6 architecture, while newer iPhones use the armv7 architecture. After you've compiled the libraries under both architectures you can use lipo (type "man lipo" in your Terminal for more info) to create a single static library with both architectures in it. If you are going to develop your app using the iPhone/iPad simulator, then I also suggest compiling once as i386 so that you can use your library with the simulator. Again, lipo can create a single static library with all 3 architectures in it.

    Now the GraphViz website appears to be unreachable at the moment, so I could not download the library and run the configure script like you did, but I suspect that before you run "make" you should make the following changes to the makefile that is produced by the configure script. Depending on which version of the iOS SDK you are targeting and what version of gcc you have on your machine you may have to tweak some of the changes below so they are appropriate for your environment. The instructions below will build for armv6. You'll need to change the settings to build for armv7 once you are ready to tackle that architecture.

    Find CC= cc and change it to: CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2

    Find -arch i386 in CFLAG and change it to: -arch armv6

    Find CFLAG and add to the BEGINNING!!: -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk

    Find SHARED_LDFLAGS=-arch i386 -dynamiclib and change it to: SHARED_LDFLAGS=-arch armv6 -dynamiclib

    0 讨论(0)
  • 2021-02-06 06:54

    Problem is imo that mkdefs is executed during the build process itself after it was created. So if you build for armv6 or armv7 the file can't be executed on the command line of Mac OS X. My workaround was to build a mkdefs for architecture i386 (which is needed for the iPhone simulator too) and copy it in the lib/gvpr directory after getting this error. Make sure that the file could not be overwritten and restart the build.

    0 讨论(0)
提交回复
热议问题