开发者

Can I compile my c++ class into static library (.a) in order to use in my iPhone project?

Due to my image processing class is written in c++ and I want to use it in my iPhone project so , Is it possible to compile this c++ class into static library (.a) and use it in my iPhone project? I also want to know about the command to compile c++ source file into static library (.a) on Mac OS-X and开发者_JS百科 how we call the c++ function that compiled into static library (.a) in Xcode.

Thank you very much.


To make your life easier, you can directly include your C++ source file into your Xcode project. In fact, if you name your Objective-C files with an .mm extension, they will be able to directly use C++ source code (this is actually called Objective C++).

On the other hand, you can make a static library with your processing class and link it to your target, but still, you will need to use Objective C++ (i.e., .mm extensions), since you will anyway need to include the C++ header files and use the compiler ABI (binary interface) to link to C++ binary.

Creating a static library from a C++ source code is no different than creating a static library from C or Objective-C code (since making a static library is simply compile+archive).

Look also at this post from S.O. for more details on the process of creating a universal static library.


Yes, you can.

The only point to notice is that in the link above, the author created an Objective-C class in .m files and headers but in your case you need to import your .cpps and headers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜