简体   繁体   English

我可以将我的 c++ class 编译成 static 库 (.a) 以便在我的 iPhone 项目中使用吗?

[英]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 库的过程的更多详细信息。

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.唯一需要注意的是,在上面的链接中,作者创建了一个 Objective-C class in.m 文件和头文件,但在您的情况下,您需要导入 your.cpps 和头文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在iPhone Xcode上将我的C ++类链接到我的C静态库.a时出现问题 - problem linking my C++ class to my C static library .a on iphone xcode 如何为我的iPhone项目在Xcode中使用第三方C库? - How do I use a 3rd party C library in Xcode for my iphone project? 如何在我的项目中使用几个C ++文件而不将每个文件都编译为C ++? - How can I use a few C++ files in my project without compiling every file as C++? 我可以在我的iPhone应用程序中使用动态库(共享对象)吗? - can I use dynamic library(shared object) in my iphone app? 为什么我无法在iPhone静态库的包中加载笔尖? - Why can't I load a nib in my bundle in my iPhone static library? iPhone SDK:如何将已编译的 static 库添加到我的项目中?(AQGridView) - iPhone SDK: How to add a compiled static library to my project?(AQGridView) 为什么使用 XCode 4 为我的 iPhone 项目构建 static 库时出现此错误? - why do I get this error building a static library for my iPhone project using XCode 4? 如何在Window中创建c / c ++库并在iPhone项目中使用? - How to create c/c++ library in Window , and use in iPhone project? 如何在iPhone项目中使用Boost uBLAS C ++库? - How to use Boost uBLAS C++ library in an iPhone project? 如何将iPhone库与iPhone应用程序连接? - How can I connect iphone library with my iPhone application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM