2015-10-27 66 views
0

我編譯libarchive用下面的命令libarchive提高編譯器錯誤在Xcode

  • 的cmake -G 「的Xcode」 〜/ libarchive下載-DIR/
  • 使
  • 使安裝

並將libarchive.14.dylibachieve.h加到我的項目中。但是我得到了一個編譯器錯誤。任何想法爲什麼?

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)

這個我試過這樣的代碼example建議:

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 

我擔心過旁邊的代碼行的警告。

enter image description here

低於lipo返回值

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

+0

這與您以前的問題(未包含頭文件)是否相同? – trojanfoe

+0

nop,這裏就像你在側面看到'archive.h'已經被添加了 –

+0

那麼這些隱式聲明警告表明你沒有包含正確的頭文件。 – trojanfoe

回答

0

你需要在你的文件的頂部導入頭:

#import "archive.h" 

至於你將它添加到庫中鏈接庫的列表?在您的目標設置中進入「Build Phases」,並檢查它是否已添加到「Link Binary With Libraries」列表中。

此外,你必須使用靜態庫,而不是共享的。使用libarchive.a而不是libarchive.dylib

+0

謝謝好主意,添加了導入行,並且我可以在「Link Binary With Libraries」中看到libarchive.dylib –

+0

請參閱我編輯的有關'libarchive.a'的答案 – deadbeef

+0

嘗試了「libarchive.a」,但現在遇到同樣的錯誤。 a「 –