Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

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?

like image 597
JulianSymes Avatar asked Oct 23 '25 19:10

JulianSymes


1 Answers

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.

like image 125
mattjgalloway Avatar answered Oct 26 '25 23:10

mattjgalloway



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!