• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding a 3rd party C++ library to ObjectiveC project
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding a 3rd party C++ library to ObjectiveC project


  • Subject: Re: Adding a 3rd party C++ library to ObjectiveC project
  • From: Koen van der Drift <email@hidden>
  • Date: Fri, 07 Jun 2013 14:13:24 -0400

Installing and building without errors has just finished.  Now the fun part start, how to even use it.

- Koen.


On Jun 7, 2013, at 1:08 PM, Todd Heberlein <email@hidden> wrote:

>
> On Jun 7, 2013, at 8:42 AM, Koen van der Drift <email@hidden> wrote:
>
>> I'd like to use an open source 3rd party C++ library in my Objective C project, but I have no idea how to do this.  I pulled the library from github, and it contains the source,  docs, and a bunch of cmake files. There is no compiled library and the docs are very scarce.
>>
>> Any suggestions how I can add and use this in my project?  Can I even use C++ within my ObjectiveC project?
>
> The short answer is "Yes, you can use C++ libraries with your Cocoa apps."
>
> The long answer is, well, a bit longer.
>
> (1) You have to build the C++ library first. That is sometimes tricky, especially for many open source projects. Once that is done, you are probably two thirds of the way there.
>
> (2) In your Xcode project, you need to set your target to (a) locate the relevant header files and (b) link against the relevant library (standard stuff).
>
> (3) You need to turn your Objective C source code files that reference any of the C++ objects to Objective-C++ code (basically change the file from a ".m" file to a ".mm" file).
>
> In general, I find I don't include C++ objects in my Objective C objects but instead include pointers to them. Then in the -init method (or appropriate place) I allocate the C++ object. This need may have changed over the years, but it has been what I've been using for several years.
>
> Todd
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Adding a 3rd party C++ library to ObjectiveC project
      • From: Jens Alfke <email@hidden>
References: 
 >Adding a 3rd party C++ library to ObjectiveC project (From: Koen van der Drift <email@hidden>)
 >Re: Adding a 3rd party C++ library to ObjectiveC project (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Xcode problems??
  • Next by Date: Re: Adding a 3rd party C++ library to ObjectiveC project
  • Previous by thread: Re: Adding a 3rd party C++ library to ObjectiveC project
  • Next by thread: Re: Adding a 3rd party C++ library to ObjectiveC project
  • Index(es):
    • Date
    • Thread