1

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.

enter image description here

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

János
  • 32,867
  • 38
  • 193
  • 353
  • Isn't this the same as your previous question (failing to include header file)? – trojanfoe Oct 27 '15 at 12:32
  • nop, here as you see on the side `archive.h` is already added – János Oct 27 '15 at 12:33
  • Well those implicit declaration warnings show you have not included the correct header file. – trojanfoe Oct 27 '15 at 12:34
  • It's a duplicate of the same question asked by you: [How to use libarchive in iOS in Xcode?](https://stackoverflow.com/questions/33366924/how-to-use-libarchive-in-ios-in-xcode) – kelin Feb 13 '20 at 10:33

1 Answers1

0

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

deadbeef
  • 5,409
  • 2
  • 17
  • 47
  • thanks good idea, import line added, and I can see libarchive.dylib in "Link Binary With Libraries" – János Oct 27 '15 at 12:42
  • tried "libarchive.a" but got the same error now for ".a" – János Oct 27 '15 at 12:45
  • What is the result of this command : `lipo -info libarchive.a` ? – deadbeef Oct 27 '15 at 13:06
  • lipo says it has architecture: x86_64, see above – János Oct 27 '15 at 14:15
  • @János You haven't built the library correctly. You need both simulator architectures (i386 and x86_64) as well as armv7, armv7s and arm64 device architectures all in one fat static library. – trojanfoe Oct 27 '15 at 14:30
  • @trojanfoe I would expect either on simulator or on device I can run app, but not, both environment raises error – János Oct 27 '15 at 14:58
  • @János Well you can see that it is attempting to run on a 32-bit simulator (arch=i386) when you only have support for 64-bit simulator (arch=x86_64). – trojanfoe Oct 27 '15 at 15:00
  • @János Try running it on an iPhone 5S or later simulator. All simulators up to iPhone 5 are 32bits if I remember correctly. – deadbeef Oct 27 '15 at 15:03
  • @trojanfoe do you have any idea how should I adjust build command up in the question to get fat static library? – János Oct 27 '15 at 15:04
  • @János That depends how you built the library. It's non-trivial cross-compiling for iOS and combining the libraries into a single fat library. – trojanfoe Oct 27 '15 at 15:07