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 11:15:47 -0700
On Jun 7, 2013, at 10:01 AM, Koen van der Drift < email@hidden> wrote: Yep, I just finished doing that :) It took a while, I needed Boost as a dependency, and used MacPorts to install that from the terminal. After that was done, I could build my library. So I now have a .a file in /usr/local/lib/ and a bunch of .hpp files in /usr/local/include/ Do I need all of these in Xcode?
Use the + button in the libraries list in the target viewer to add the library. It’ll show up in the list since it’s in a known location. You can just include the headers with #include <headername.hpp> since they’re in the standard system includes directory. No need to add them to your project. The library is just used with one of my ObjC files, so I'll start with renaming that to .mm. If that doesn't work, I'll look into the wrapper as you suggested.
Cool. The usual problem people run into is C++ syntax leaking into source files not being compiled with Objective-C++. A common mistake is to add “#include <blah.hpp>” in the header file of an Obj-C class — when that header gets #imported from a .m (not .mm) file, the parser isn’t expecting C++ syntax and will barf. The barfage may happen way down in some C++ standard library header and be very confusing if you don’t realize what’s going on.
—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