libarchive raise compiler error in iOS in Xcode

狂风中的少年 提交于 2019-12-25 06:39:58

问题


I compiled libarchive with following commands

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

and added libarchive.14.dylib and achieve.h to my project. But I got an compiler error. Any idea why?

Undefined symbols for architecture i386:
"_archive_read_support_filter_all", referenced from: -[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried this code like example propose:

struct archive *a;
struct archive_entry *entry;
int r;

a = archive_read_new();
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
r = archive_read_open_filename(a, "archive.tar.gz", 10240); // Note 1

I am worried about the warning too next to the code lines.

below the lipo return value

lipo -info /Users/extjanos/Desktop/temp2/libarchive/libarchive.a input file /Users/extjanos/Desktop/temp2/libarchive/libarchive.a is not a fat file Non-fat file: /Users/extjanos/Desktop/temp2/libarchive/libarchive.a is architecture: x86_64


回答1:


You need to import the header at the top of your file :

#import "archive.h"

As for the library did you add it to the list of linked libraries ? In your target settings got to "Build Phases" and check that it has been added to the "Link Binary With Libraries" list.

Also you must use the static library and not the shared one. Use libarchive.a instead of libarchive.dylib



来源:https://stackoverflow.com/questions/33367979/libarchive-raise-compiler-error-in-ios-in-xcode

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