Vaibhav Tekam
Vaibhav Tekam

Reputation: 2344

Cross Compilation for iOS! what it takes at all?

I am supposed to use Podofo library in my iPhone project, in order to deal with PDF. Podofo is a library written in 'C', which allows you to play with PDF's. Now this Podofo does already have some other dependencies on other libraries or frameworks, like ..

freetype2, fontconfig, etc. which can all be satisfied just by installing Macports on your Mac OSX.

Intially I tried to create a static library from Podofo source files using commands given on the Podofo website. It did create a library, but it was not build for arm architecture. So when I tried to include that library in my Project, it threw error. So I started searching for the steps for cross compilation for iOS. The posts that I read says, that the process is quite painful.

I see one around, in which I can directly add the C-Source files to my project and use it. But still I have some question regarding cross-compilation+static library.

Is it really a very complex process? I know what is cross compilation. But I don't know the exact steps to do it using XCode or any other tool, so that the compiled build can be used in iPhone project. Can anyone put some time and effort, to list down all the possible steps and pointers, so that guys like me can have it as a reference in future.

Upvotes: 3

Views: 591

Answers (1)

user457812
user457812

Reputation:

There isn't really a specific list of steps for all libraries. You would have to set up PoDoFo differently than you would something else, you just have to sit down and do it.

At its most convenient (that is, for using the library), the process would probably involve creating an Xcode project for the library and setting it up to build as a framework. This is fairly simple for iOS, seeing as you can only statically link to third-party libraries on the platform. As such, it's mostly just a matter of setting up a project to build a framework, adding the relevant files and compiler/linker flags, and setting the headers' visibility for the framework where necessary.

For other libraries, you may be able to change CFLAGS/CPPFLAGS/CXXFLAGS/LDFLAGS and build the static library from the command line. This is less convenient, but ultimately produces roughly the same result. Frameworks just tend to be a little easier to work with. Again, you have to approach each library on its own and decide what the best option is and do it that way.

Also, a warning note about PoDoFo:* it's licensed under the LGPL, meaning you cannot use it on iOS without violating the license. By statically linking to the library, you would be creating a derivative work based on the original software, meaning your software would then have to be licensed under the LGPL as well.

* Bearing in mind that I am not a lawyer, but I've spent a lot of time reading the various open source licenses. For actual legal help regarding open source licenses, speak to a lawyer.

Upvotes: 6

Related Questions