Creating Static Graphviz Libraries for iOS

I am trying to create static libraries for Graphviz to include them in an iOS application, but I cannot get it to work. Here is what I have done so far using graphviz 2.28.0], Xcode 4.1, OSX 10.7, and I am aiming for an iOS simulator.

I found instructions for setting up Glen Low and with some informed guesses updated them to:

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

This works, but then "make" works for a while, and the errors are:

 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 

I don’t quite understand all the specifications of the architecture, so any help to get this to work is welcome.

+6
ios objective-c ios4 graphviz
Aug 28 2018-11-11T00:
source share
3 answers

I got this job. The script construct failed when it tried to make an executable file, since it was compiled for i386 instead of x86 or x86_64, but all the libraries are 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 
+2
May 2 '12 at 17:29
source share

The problem is that mkdefs is executed during the build process itself after it is created. Therefore, if you create for armv6 or armv7, the file cannot be executed on the Mac OS X command line. My workaround was to build mkdefs for the i386 architecture (which is also necessary for the iPhone simulator) and copy it to lib / gvpr after receiving this error. Make sure the file cannot be overwritten and restart the assembly.

+1
Jan 06 2018-12-12T00:
source share

The linker seems to be trying to link to the system libraries installed on your Mac. All libraries are built for i386 or x86_64, which are not going to work when compiling libraries for the iPhone. You will need to reconfigure the linker to communicate with the libraries included in the iPhone SDK.

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

Now the GraphViz site is currently unavailable, so I could not load the library and run the configure script, just like you, but I suspect that before you run "make" you should make the following changes: make file created by configure script. Depending on which version of the iOS SDK you are targeting and which version of gcc you have on your computer, you may need to modify some of the changes below to suit your environment. Below are instructions for armv6. You will need to change the build settings for armv7 as soon as you are ready to tackle this 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 START !!: -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
Sep 25 '11 at 13:15
source share



All Articles