Build static Graphviz libraries for iOS - objective-c

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 4.1, OSX 10.7 and I am targeting the iOS simulator.
I found Glen Low's configure instructions, and with some informed guesswork updated these 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 the "make" runs for a while and errors out with:
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 architecture specifications, so any help to get this to work is most welcome.

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.

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

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

Related

Cannot combine the resulting libraries using the lipo command

Going to develop an iOS VoIP app as my final project, but not finding a proper SDK to be used for making app to work like Skype/ Viber, for Voice and Video Call.
Or suggest me another FREE library.
I working on this from the previous 2 months...
Thanks.
EDIT:
When I perform 'lipo' command this occurs:
iMac-2:lib mac$ lipo -arch libpj-arm64-apple-darwin_ios.a -arch libpj-armv7-apple-darwin_ios.a -arch libpj-armv7s-apple-darwin_ios.a -arch libpj-x86_64-apple-darwin16.0.0.a -create -output libpjlib.a
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: unknown architecture specification flag: libpj-arm64-apple-darwin_ios.a in specifying input file -arch libpj-arm64-apple-darwin_ios.a -arch
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: known architecture flags are: any little big ppc64 x86_64 x86_64h arm64 ppc970-64 ppc i386 m68k hppa sparc m88k i860 veo arm ppc601 ppc603 ppc603e ppc603ev ppc604 ppc604e ppc750 ppc7400 ppc7450 ppc970 i486 i486SX pentium i586 pentpro i686 pentIIm3 pentIIm5 pentium4 m68030 m68040 hppa7100LC veo1 veo2 veo3 veo4 armv4t armv5 xscale armv6 armv6m armv7 armv7f armv7s armv7k armv7m armv7em arm64v8
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo [input_file] ... [-arch <arch_type> input_file] ... [-info] [-detailed_info] [-output output_file] [-create] [-arch_blank <arch_type>] [-thin <arch_type>] [-remove <arch_type>] ... [-extract <arch_type>] ... [-extract_family <arch_type>] ... [-verify_arch <arch_type> ...] [-replace <arch_type> <file_name>] ...
If you got errors in library means, Either you have not properly configure the PJSIP project in Your system (or) you missed any library that you want to add in your xcode project.
If you want to run project in simulator or iphone?
There is two different configuration for pjsip project. For iphone and simulator, configuring project is different.
For properly configure your PJSIP Project in your system, follow this below link.
Source : https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone
Please post the error message completely in your xcode, to solve the problem.
You missed architecture name
was:
lipo -arch libpj-arm64-apple-darwin_ios.a -arch libpj-armv7-apple-darwin_ios.a ...
Need:
lipo -arch arm64 libpj-arm64-apple-darwin_ios.a -arch armv7 libpj-armv7-apple-darwin_ios.a ...
For each -arch you need set name and than lib name

Renaming Quicklook-template GeneratePreviewForURL.m causes linker error

I'm using a slightly outdated version of Xcode (4.2.1, with Apple clang version 3.0), which might be a problem, but.. this should work regardless:
I create a new Quicklook plugin project ("File > New > New Project", then "System Plugin > Quick Look Plug-in")
Then I rename GeneratePreviewForURL.c to GeneratePreviewForURL.m (as mentioned in the Apple docs)
If I try and use any Objective-C code in the file, I get errors. For example if I add the following to the GeneratePreviewForURL method:
#include <Foundation/Foundation.h> // at start of file
NSMutableDictionary *blah;
[blah setValue:#"valuething" forKey:#"keything"];
I get the following linker error:
Undefined symbols for architecture x86_64:
"_objc_msgSend", referenced from:
_GeneratePreviewForURL in GeneratePreviewForURL.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The slightly trimmed/reformmated linker command causing the problem is:
cd ~/QuicklookExample
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang
-arch x86_64 -bundle
-isysroot /Developer/SDKs/MacOSX10.7.sdk
-L/snip -F/snip -filelist /snip/QuicklookExample.LinkFileList
-mmacosx-version-min=10.7
-framework QuickLook
-framework ApplicationServices
-framework CoreServices
-framework CoreFoundation
-o /snip/QuicklookExample
You have to add at least Foundation framework to the linked libraries.
Note that what's missing here is libobjc which should be linked directly by the fact clang should understand your code is actually Objective-C.

Compiler Error in Xcode-4 Cocoa Application For GData Api?

I am trying to Fetch Videos from YouTube Channel on Cocoa Application. For that First added GData Framework to my project, and import #import "GData/GData.h". Then their is no error . But if i am importing #import "GData/GDataServiceGoogleYouTube.h"
and write some code related to GDataServiceGoogleYouTube
GDataServiceGoogleYouTube *service=[[GDataServiceGoogleYouTube alloc]init];
getting Compiler eror:
Ld /Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug/YouTube.app/Contents/MacOS/YouTube normal x86_64
cd /Users/Rasheed/Desktop/MULTIPLESOCKET/YouTube
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.6.sdk -L/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug
-F/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug -filelist
/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth
/Build/Intermediates/YouTube.build/Debug/YouTube.build/Objects-normal/x86_64/YouTube.LinkFileList -mmacosx-version-min=10.6 -ObjC
-lxml2 -all_load -framework Cocoa -o /Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build
/Products/Debug/YouTube.app/Contents/MacOS/YouTube
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GDataServiceGoogleYouTube", referenced from:
objc-class-ref in YouTubeAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can i Fix This error?
If you built a GData static library, make sure the library is listed in the “Link Binary With Libraries” section under the “Build Phases” tab for your target.
If you dragged all of the GData source files into your project, make sure they are all listed in the “Compile Sources” section under the “Build Phases” tab for your target.
You might find this blog post helpful: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/

libmms linking error

i have downoaded the wunder radio project, i have copy the MMS project in my workspace.
if i try to use mms_connect Xcode4 give me this error:
Ld
/Users/Alex/Library/Developer/Xcode/DerivedData/test1-gevnovbiecnctxguaabsznvdybxa/Build/Products/Debug-iphonesimulator/test1.app/test1
normal i386
cd /Users/Alex/Source/test1
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH
"/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
-arch i386 -isysroot
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
-L/Users/Alex/Library/Developer/Xcode/DerivedData/test1-gevnovbiecnctxguaabsznvdybxa/Build/Products/Debug-iphonesimulator
-F/Users/Alex/Library/Developer/Xcode/DerivedData/test1-gevnovbiecnctxguaabsznvdybxa/Build/Products/Debug-iphonesimulator
-filelist
/Users/Alex/Library/Developer/Xcode/DerivedData/test1-gevnovbiecnctxguaabsznvdybxa/Build/Intermediates/test1.build/Debug-iphonesimulator/test1.build/Objects-normal/i386/test1.LinkFileList
-mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lz.1
-framework UIKit -framework Foundation -framework CoreGraphics -o
/Users/Alex/Library/Developer/Xcode/DerivedData/test1-gevnovbiecnctxguaabsznvdybxa/Build/Products/Debug-iphonesimulator/test1.app/test1
Undefined symbols for architecture i386: "_mms_connect", referenced
from:
-[test1AppDelegate application:didFinishLaunchingWithOptions:]
in test1AppDelegate.o ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
have any idea to resolve it?
It looks like the linker is failing to link to libmms because it is of the wrong architecture. The project you are building appears to be for the iPhone simulator. Since the simulator runs on your computer it's architecture is i386 (or perhaps x86_64 depending upon the machine you are using). So basically you are compiling using i386 but when the linker tried to link to libmms it did not find that libmms had been compiled using the same architecture.
Since iOS devices use armv6 or armv7 architectures and the simulator uses i386, it can be quite difficult to switch back and forth between building for the actual device or building for the simulator since any external static libraries need to be built for all 3 architectures.
You'll likely need to rebuild libmms using the i386 architecture.

Error installing mod_wsgi 3.2

I am trying to install mod_wsgi 3.2 on Mac OSX 10.6.6 and am getting this error when I attempt to make
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
lipo: can't open input file: /var/folders/XW/XWYalsEzG3Gkn+PhoNKF0k+++TI/-Tmp-//ccsEgbTa.out (No such file or directory)
apxs:Error: Command failed with rc=65536
.
make: * [mod_wsgi.la] Error 1
This is a late answer, but I found a solution in my searching and wanted to include it here for others. This error typically occurs because you are trying to build libraries for ppc architecture which won't work as xcode4 doesn't no longer includes support for ppc. You can get around this by setting the following in your environment before running your build (I put this in my .bash_profile so I don't beat my head against the wall later):
export ARCHFLAGS="-arch i386 -arch x86_64"
The latest mod_wsgi version is 3.3 for a start, why are you using 3.2? Second, there is a precompiled mod_wsgi.so binary for MacOS X which can be used for Apple supplied Python and Apache, so you do not need to compile it from source code and so avoid need to have installed XCode development tools. The precompile mod_wsgi.so is available from mod_wsgi download page.
As to the errors, it would appear to be a permissions problem for user that you are compiling as. That or you aren't using standard Apple supplied software and have somehow mixed up your PATH so it is grabbing disparate tools from different package distributions. Are you using just Apple tools or have you installed any of MacPorts, fink or HomeBrew?
Edit the Make file like:
CPPFLAGS = -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DNDEBUG
CFLAGS = -Wc,"-arch i386" -Wc,"-arch x86_64" -Wc
LDFLAGS = -arch i386 -arch x86_64 -F/Library/Frameworks -framework Python -u _PyMac_Error
LDLIBS = -ldl -framework CoreFoundation
I had the same question
In the end,I found I don't have write permission of '/usr/libexec/apache2/'
then I add chmod +w to the folder,,
then install success !!
Hope my answer can be a refer for some others
Good Luck!