yachiro
yachiro

Reputation: 59

loading C shared library with Xcode project Objective C

I'm a beginner with MacOSX and I want to know if it's possible to load a shared library (dylib) written in "C" with a Xcode project written in Objective C and if yes how can I do it.

If you have an example of a case like this one it would be very useful.

Upvotes: 4

Views: 905

Answers (1)

squeeks
squeeks

Reputation: 1269

There are plenty of use cases for doing this - especially on OS X specific development it lets you access a lot of common libraries so you don't have to reinvent wheels.

To use the various libraries, either add them in the Linked Frameworks and Libraries section in the Summary panel in your application, or just drag the files into your project - they typically live in /usr/lib/.

For example, if I wanted to take advantage of using various tools as part of OpenSSL - drag in the libcrypto.dylib file into the project, and then at the top of each file I wanted to use the library, I would just have to #import whatever headers to access the various functions provided - it helps to read the respective library's documentation.

Upvotes: 4

Related Questions