views:

1929

answers:

3

Hi guys,

The motivation for this question is me trying to get LDAP functions to work with an iPhone application which is a project I'm attempting for part of my dissertation.

When I was developing the application I used the ldap.framework framework that is part of Mac OS X. This works fine in the simulator, but when I try to now get the app on a device it tells me that I'm not allowed to use this framework.

After some research I found that I could build openldap using the arm architecture and add the static library to my application destined for my device.

I eventually managed to compile configure and build openldap by setting variables as mentioned here and using the following commands...

Ade$ ./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 \
LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --with-yielding_select=yes
Ade$ make depend
Ade$ make

I was told that the file I'm looking for will have an extension of '.a' so I searched for a '.a' file that mentions ldap...

Ade$ sudo find / -name *ldap*.a
Password:
/Users/Ade/Desktop/openldap-2.4.16/libraries/libldap/.libs/libldap.a
/Users/Ade/Desktop/openldap-2.4.16/libraries/libldap_r/.libs/libldap_r.a

So I assume these are the files I need?

My question is what do I do next? I know I need to add the library to the Xcode project and probably add a load of '.h' files too?

If anyone can give me a pointer to documentation or shed any light on the next stage I would be really grateful.

Many thanks, Ade

ps. I have also talked about this process on my blog at www.greenpasta.com.

A: 

Simply drag the .a files into the Xcode project and choose "copy files into project". I'm not familiar with OpenLDAP but I think the _r version is just a threadsafe version. I would recommend using that and not copying the other. You should probably not copy both files into Xcode or you will get link errors.

Then do the same for the .h files that define the client APIs of OpenLDAP - again I'm not sure which these are but I'm sure you can find out easily.

I would advise organising the .a and .h files together in a Xcode group under resources.

Include the header files in your source and you should be good to go.

Roger Nolan
Hi,I tried this method but didn't get any closer...There's another discussion going on on the Apple Discussion Boards...
Ade St John-Bee
A: 

You may also need to add -lldap to your linker command (in the build settings pane).

Marc W
+1  A: 

I've done this same thing to build an LDAP client for the iPhoneOS 2.2. You just to drag the .a into the "link with libraries" build stage. I recommend using the regular (non _r) version of the library, unless you specifically need reentrancy on your ldap stuff (which I don't recommend). You can also add the .h's to your project, which is generally the easiest way to access them.

Rob Napier