简体   繁体   English

将C ++代码编译到静态库(.a)

[英]Compiling C++ code to static library (.a)

So i asked some questions before regarding this, but i think i am finally getting closer to my goal of using a C++ Library in a Swift iOS Project. 因此,在此之前我问了一些问题,但是我认为我终于接近了在Swift iOS项目中使用C ++库的目标。 I have downloaded a C++ Library as tar.gz. 我已将C ++库下载为tar.gz。 To use this library i am supposed to install it on my computer using make, but i want it as aa static library (.a to my knowledge) to use it in a Swift App. 要使用此库,我应该使用make在计算机上安装它,但是我希望它作为一个静态库(据我所知为.a)在Swift App中使用它。 I know how to use C++ in a Swift project thats working and running. 我知道如何在可以正常运行的Swift项目中使用C ++。 But i can't find any helpful advice on how to compile this source to a static Library. 但是我找不到任何有关如何将此源编译为静态库的有用建议。 You can download the Library here . 您可以在此处下载库。 I just need it in a .a file and don't really know how to start. 我只需要一个.a文件,并不知道如何开始。 Everything i am finding is using headers and things i absolutely do not know. 我发现的所有内容都使用标题,而我绝对不知道。 Please excuse my confusion, I am an absolute newbie in C++. 请原谅我的困惑,我绝对是C ++的新手。

Thanks a lot for future advice =) 非常感谢您将来的建议=)

And this is the structure of the archive. 就是档案的结构。

You need to compile the code and link it with your compiler. 您需要编译代码并将其与编译器链接。 Suggested steps: 建议的步骤:

  1. Run make in the top-most folder of the source code 在源代码的最顶层文件夹中运行make

  2. Find the location of the library file by running find . -type f | grep "\\.a$" 通过运行find . -type f | grep "\\.a$"库文件的位置find . -type f | grep "\\.a$" find . -type f | grep "\\.a$" find . -type f | grep "\\.a$" in the terminal. find . -type f | grep "\\.a$"在终端中。

  3. Add the path to the library file in your IDE or compiler. 将路径添加到IDE或编译器中的库文件。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM