问题
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