Note that there are some explanatory texts on larger screens.

plurals
  1. POCall of a wrapped static c++ library in an objc library causes linker error
    primarykey
    data
    text
    <p>I have a cpp static library and tried to wrap this in a static obj-c library so that it looks from the outside like a normal obj-c lib. My obj-c lib compiles fine, but when i try to use this lib in an App I get the following Linker error:</p> <pre><code>Apple Mach-O Linker (Id) Error Undefined symbols for architecture i386: "operator new(unsigned long)", referenced from: ... </code></pre> <p>All libs compile fine in every needed architecture.</p> <p>My wrapper lib looks like this:</p> <p>ObjcLib.h</p> <pre><code>@interface ObjcLib: NSObject{ } - (void) doSomething:(NSString*)text; @end </code></pre> <p>ObjcLib.mm</p> <pre><code>#import "ObjcLib.h" #import "apiFromCppLib.h" @interface ObjcLib (){ @private cppApiNamespace::BaseApi* api; } @end @implementation ObjcLib - (void) doSomething:(NSString*)text{ api = new cppApiNamespace::BaseAPI(); } </code></pre> <p>In my App I added ObjcLib.a under Link Binary With Libraries. Also the Library Search Path is correct, but when i try to create an object with [ObjcLib alloc] I get the above mentioned Linker Error. I am Using XCode4 with the LLVM Compiler 3.0</p> <p>Hope anyone can give me an hint what could be wrong or if my wrapper is even right.</p> <p>EDIT: adding -lstdc++ as an Other Linker Flag in the Build Settings of the App solves a lot of the Linker errors but not all. Thoses which were solved were cpp commands in ObjcLib.h and ObjcLib.mm. Thoses who remain are some method calls from within the BaseAPI. Will have a closer look to this, about what makes this method calls different from those others which could linked correctly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload