Re: Adding a 3rd party C++ library to ObjectiveC project
Re: Adding a 3rd party C++ library to ObjectiveC project
- Subject: Re: Adding a 3rd party C++ library to ObjectiveC project
- From: Jens Alfke <email@hidden>
- Date: Fri, 07 Jun 2013 09:45:07 -0700
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.
It’s probably easiest to just use the supplied makefile/scripts to build the library, rather than trying to get Xcode to build it. As long as the build process outputs a library of some sort (.dylib or .a) you can add that file to your Xcode project.
Any suggestions how I can add and use this in my project? Can I even use C++ within my ObjectiveC project?
Sure. If you want to call C++ APIs (or include any headers that have C++ syntax) from Objective-C code, change the suffix of that source file from “.m” to “.mm” to enable Objective-C++. The compiler will then recognize both Objective-C and C++ syntax.
I recommend making an Objective-C wrapper around the C++ API. Then the only .mm files you need are for the ones that implement that wrapper. The rest of your app can just use the Objective-C API and not have to worry about C++.
—Jens |
_______________________________________________
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