How to use libarchive in iOS in Xcode?

匆匆过客 提交于 2021-02-11 15:19:42

问题


I want to add libarchive to my app to be able to extract tar.gz.

As install instruction says, I took following steps:

  • cmake -G "Xcode" ~/libarchive-download-dir/
  • make
  • make install

Now I have a libarchive.14.dzlib file. I added it to the project, and wants to call i.e. the following, like proposed in examples

r = archive_read_open_filename(a, "archive.tar", 10240);

but, method is not declared.

I guess I have to add a header to the project?! It is a dylib, I am not sure. But I do not found any appropriate header file in the build folder.

How can I use libarchive, what am I missing to call one method, which methods are available where is a header?


回答1:


Yes, you need to add the header. The archive.h header that is in the libarchive directory is sufficient, you don't need the other ones.




回答2:


Looks like you've simply forgotten to include the header file and so the compiler assumes any undefined functions return int.




回答3:


If you correctly downloaded libarchive sources, they should include source .cpp and .h files - look here https://github.com/libarchive/libarchive/tree/master/libarchive



来源:https://stackoverflow.com/questions/33366924/how-to-use-libarchive-in-ios-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!