JulianSymes
JulianSymes

Reputation: 2215

How should I get Xcode to link an iOS project that uses a C++ static library

Using Xcode, I've written a Cocoa Touch static library, mainly in C++. It exposes a C interface for the benefit of Objective-C client code.

I have a client iOS app that uses it, and everything works and runs as expected, except that I found I needed to include a minimal .cpp file in the client project to get the link to succeed. Otherwise I get C++-related unresolved symbols, e.g. operator new(unsigned long).

The above hack is easy and effective, and so I guess I'm not breaking any laws, but is there a proper way to eliminate my linker errors?

Upvotes: 4

Views: 3428

Answers (1)

mattjgalloway
mattjgalloway

Reputation: 34912

Should be just a matter of adding -lc++ to the linker flags in the project settings, I'd have thought.

Add it under "Other Linker Flags" under "Linking" section of the "Build Settings" tab on your project's settings.

Upvotes: 6

Related Questions