Include static C++ library to Objective C project -


i want create c++ library , include in objective c code. work in xcode. here c++ code:

--------------core.cpp----------

#include <vector> #include <algorithm>  extern "c" void my_sort(std::vector<int>& a) throw() {  sort(a.begin(), a.end()); // std::vector's sort function  } 

so want create library including in obejctive c code. how include or import ? .. want call my_sort() function ?

thanks !

the trouble here function has external c linkage. hence cannot use arguments of type std::vector, neither throw declarations these c++ stuff.

to include objective c code, have write accompanying header file, declare exported function. easier export once have removed references c++ interface. avoid need include c++ headers.

then, use objective c code, #include header file, , give linker information library.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -