[英]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? 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 how we call the c++ function that compiled into static library (.a) in Xcode. I also want to know about the command to compile c++ source file into static library (.a) on Mac OS-X and 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.为了让您的生活更轻松,您可以将 C++ 源文件直接包含到 Xcode 项目中。 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++).实际上,如果您将 Objective-C 文件命名为.mm
扩展名,它们将能够直接使用 C++ 源代码(这实际上称为 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++ (ie, .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. 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++ (ie, .mm extensions), since you will anyway need to include the C++ header文件并使用编译器 ABI(二进制接口)链接到 C++ 二进制文件。
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). 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 SO for more details on the process of creating a universal static library.另请参阅SO的这篇文章,了解有关创建通用 static 库的过程的更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.