views:

136

answers:

1

Pardon me if this is a "noob" question, I'm overextending myself a bit with this.

I'm trying to compile a library written in C for use in an iPhone app I'm developing. I can't seem to figure out how to do this, and I've been searching and trying things for hours.

I've tried using an External Build System project, and selecting the folder where the makefile.in.am.mingw are.

I've tried creating a Static Library project and adding the header\source files to the project. Which looked good until I tried to compile and got 260k+ errors.

When I 'cd' to the directory with the makefiles and type 'make' I get:

No targets specified and no makefile found. Stop.

I have no idea how makefiles work, I just want to use the library!

Is there a simple way to do this? If someone could at least point me in the right direction, I would be quite appreciative.

+1  A: 

The makefiles you have are for GNU automake (under MINGW by the look of it). Even if you get them working (automake can be tricky, but it is included in Mac OS X's development thankfully), it probably won't help you much in building an iPhone library.

I did this with an existing C library by creating a new framework target in Xcode with the right include settings, etc gleaned from looking at the makefiles. That created a .framework bundle with headers and an iPhone .a library ready to be used by an iPhone project. You could also just import the C source into the iPhone project, and have it compiled in that way which would probably be quicker.

Matthew Phillips
Could you elaborate on this? I tried just importing the C source into the iPhone project. I got like 260k errors. A .a library would be all I need.
Mike A
If you can try to summarise the sort of errors you're seeing, I can try to be more specific.That many errors sounds like it's probably due to you needing to add header file include paths for project you're importing (see "User Header Search Paths" in the project's Xcode Info dialog).
Matthew Phillips
The bulk of the errors are : Expected '=',',',';','asm'or'_attribute_' before 'staticlibrary_value_get_x' OR Expected declaration specifiers or '...' before 'x' OR Declared as function returning function. Stuff of the sort. I tried setting the User Header Search Paths to the directory where the library source is, and making it recursive. No change.
Mike A
@Mike A: It sounds like it could be trying to interpret the source in the wrong language or wrong dialect.
dreamlax
Yes, those errors sound like the compiler is failing to parse at a pretty fundamental level.Mike A, I think you're either going to need to let us know what the library is, or post some source from it if you want to get any further here.
Matthew Phillips
The library is libpurple :S
Mike A
Try looking at the Xcode project file for Apollo IM then (http://code.google.com/p/apolloim/). It's an IM app for iPhone that also uses libpurple.
Matthew Phillips
I have looked at this already. Was actually the first thing I checked out. The ApolloIM team built libpurple.framework during the early days of the iOS SDK beta. Apple has since declined to approve 3rd party frameworks on the iPhone, which is why I'm opting for building this as a static library, which seems to be the way to go... and coincidentally where I'm stuck.
Mike A
I'm not sure I understand "declined to approve 3rd party frameworks on the iPhone"? Third party frameworks are most definitely allowed, and widely used, e.g. the 360 UI components from Facebook. Do you mean dynamic libraries?I can only suggest that you look at how libpurple is built in the Apollo IM top-level Makefile and go from there http://code.google.com/p/apolloim/source/browse/trunk/apolloim-1.0.1-REV3/Makefile.
Matthew Phillips
Thanks for your help.
Mike A