How to compile third party c library in Xcode? - iphone

i tried to do a sip client for iphone.
I tried to use oSip or eXosip2 , i download their package ,and compile it using "./configure""make""make install "
I get some *.a library, and i include there headers.
When i compile it , their is warning , this *.a library formate doesn't support !
It's really annoying, what should i do to make it work ?
Should i include their code ,and compile in xcode ,tried to build a static library ?
somebody tell me ,how to deal with some C librarys.
I see some topics talk about how to make a library in xcode . The problem is , if it is C library , it was already done, no need to build in xcode ,it's already their ,just make to build it . Whatif the *.a library doesn't support ,what should i do ??
PS: I was already doing the static library ,not dynamically. It's not a chooice between dynamically and static . It's all about x86_64 PC LIB is not suitable for i386 iphone.

You can't dynamically link on the iPhone; it has to be static linking.
Should i include their code ,and compile in xcode ,tried to build a static library ?
Yes, I think so.
Maybe have a look at this previous question: How do I add a third party Framework to iPhone project?

In order to compile for iOS, you should create an xcode project. It will be much easier to use, maintain and debug.
You can download here my osip/exosip/c-ares xcode project.
The above also requires c-ares which is an important dependancy for eXosip2.
PS: minor update may be required to compile git version. Just add/remove new/old files.

Related

Embedding Frameworks from SwiftPM into Cocoa Application (XCODE)

I'm using a project called "HAP" (https://github.com/Bouke/HAP) that is built using SwiftPM.
The included example "HAP-server", works great from Command Line and I have used the params "swift package generate-xcodeproj" to create an XCODE project.
I can also load the HAP in XCODE and build/debug the target "HAP-server".
I'd like to use this framework in my Cocoa Application and have added the HAP.xcodeproj into my project. I added the produced files as "Embedded Binaries" and "Linked Frameworks and Libraries".
That allows me to "import HAP" into my view controller class.
However, when I try to build my Cocoa target, I get the following message -- seems related to the dependency "Kitura-net" from the HAP project...
"Missing required modules: 'CCurl', 'CHTTPParser'"
What is the best way to use frameworks from a SwiftPM in my project?
I assume it has something to do with Search headers... anyone have an idea?
UPDATE #1:
I have tried adding to my Cocoa Project that is importing the library that is using Kitura by "Link Binary With Libraries", libcurl.4.dylib from usr/lib/ but it still gives me the same error.
UPDATE #2:
UPDATE #3
I ended up figuring it out by using this method: Importing CommonCrypto in a Swift framework
I needed to create a modulemap for each of the items it was throwing a fit about, in my case: CCURL & CHTTPParser. Once I did that, I could compile.
You can see an example of embedding Kitura in an Xcode project in this repo https://github.com/IBM-Swift/Kitura-HelloWorld-iOS. Makefile in this repo runs build scripts to fix an Xcode Project to run Kitura on iOS. You need to compile curl for iOS - see instructions in the README.
From what I remember, you need to add the directory with curl headers to Header Search Paths, the directory with libcurl.a to Library Search Paths, and also add -lz flag to Other Linker Flags.

pjsip build for iOS 5, won't make

I retrieved the latest build from the SVN trunk on Friday and attempted to build following the directions on the getting started wiki.
make dep seems to execute without any problems, but make fails on Samples.mak. It appears there are no rules to make any of the samples when the platform is "arm-apple-darwin9".
If I open the Xcode project at this point, libavcodec and all it's related libraries are missing as well as LibSDL. There's not mention of a requirement to install SDL and ffmpeg beforehand, so not sure what to do there.
Please add some framework is required for run pjsip and also checked config_site.h this file available or not if not found then add this file. some code also may to write in config_site.h file .

DYLD_INSERT_LIBRARIES and iPhone

I understand that Apple doesn't support using dynamic libraries in iPhone applications. But we are working on a in-house application and we have a unique requirement to use the dynamic libraries. Our requirement is to load a dynamic library as part of "iPhone" application start up. I read that DYLD_INSERT_LIBRARIES is meant for this purpose. So I edited the Info.plist and added below entry.
LSEnvironment
DYLD_INSERT_LIBRARIES
#executable_path/sample.dylib
But it does not seem to be working. Can you please let me know your thoughts ? Really appreciate your help in this regard.
Thanks
--Neo
I've found a way to successfully add LC_LOAD_DYLIB load command to a MachO binary using optool.
$ optool install -c load -p "#executable_path/<dylib_path>" -t <executable>
$ otool -L <executable>
When building optool, make sure that build setting OTHER_LDFLAGS includes -ObjC.
optool does not seem to be able to successfully add load commands for arm64 architectures, so you may want to remove arm64 from the binary
$ lipo <input_file> -remove arm64 -output <output_file>
Edit:
There is an open pull request with support for arm64.
I also working on the same problems for last few days. I also didn't succeed to do it the way you try. So I try to launch my app from another app using this link:
Dynamic Library injection
,unfortunately Apple Block running multiple tasks (even on iphone simulators) but you can try maybe you will have more luck. I know its not a answer you expect but maybe it will give you some way to think. Please share if you have some progress.
You "could" load a binary at runtime and you can manipulate xcode settings to make it compile dylibs for iOS. See this answer:
https://stackoverflow.com/a/10509453/784387
Happy to be corrected, but dylibs are not supported and will not work. You need to get the code for the libraries and compile them into a static lib for the arm6/7 architecture. Then you can easily include these libs. There are plenty of examples of static libs and XCode also provides targets for building them.

Correct configuration to build libsrtp for the iphone?

I'm trying to build libsrtp so that I can use it on the iPhone (I intend to use it with libav's implementation of RTP).
My configuration:
./configure
--build='arm-apple-darwin9'
The warning I get when I attempt to call srtp_init():
file was built for unsupported file
format which is not the architecture
being linked (armv7)
Followed by the error:
"_srtp_init", referenced from:
+[Manager initialize:] in Manager.o
Symbol(s) not found
Does anyone know the proper configuration for building the library correctly?
The problem is it's not being built for ARM (or not for the right ARM; you need to look at which compiler is bing invoked with which options, and compare it to one you know is working). Did you do rebuild configure with autoconf? See the GNU build system wiki page for a starting point on how to reconfigure the build for other systems/processors.
FYI, if you find a bug in the configure.in or other parts of libsrtp, please let me know - I'm an author on it with checkin privs.
For general guidelines on cross compiling libraries for iOS I recommend this article:
http://tinsuke.wordpress.com/2011/02/17/how-to-cross-compiling-libraries-for-ios-armv6armv7i386/
The same guy also wrote an updated version for iOS 5. This one is specific to the tesseract library, but the general principles are the same:
http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/.
Using these as a guide I've had some success compiling a few libraries. Key things to note are that you have to disable compiling shared binaries. Also I recommend using clang rather than gcc.

XCode linker error : library not found for -lAdMobDevice

I am trying to build lite version of my iPhone application using AdMob. I followed the guidelines here http://www.iphonedevsdk.com/forum/iphone-sdk-development/11358-creating-lite-version-app.html and created two different targets. In the lite version I added a macro called LITEVERSION which I am checking using #ifdef and doing the appropriate things.
But when I build the lite version of the app, I get a linker error
ld: library not found for -lAdMobDevice
collect2: ld returned 1 exit status
However I am able to build the full version without any issues and also noticed that build is working fine (for the fullversion) even if I remove the #ifdef macros. This suggests that the libAdMobSimulator.a library is linking properly for the full version however it fails on the lite version.
Any pointers would be greatly appreciated!
Cheers
Jugs
When I had this problem, the cause was that I'd added the library into Xcode by dragging it in like a regular source file.
The fix was to remove it, and then add it properly using the "Add->Existing Frameworks..." dialogue.
I got similar error as I was using CocoaPods libraries
library not found for -lPods-MyApp
I got the error because I opened xcode project instead of workspace.
I was using CocoaPods, and ran pod install, and that fixed it.
I figured out what he problem was. I just removed all frameworks and libraries and added them back in for both the targets and it worked!
Cheers
I cause this because of a libray libMobClickLibrary.a which is used in youmeng sdk missed. I fix the issued after copy libMobClickLibrary.a to the project floder.
I had the same problem with Google Analytics library. My problem was that I forgot to add the path to the Library Search Paths in my target's build settings. (Target -> Build Settings -> Library Search Paths)