2015-01-05 172 views
1

在我爲某些iOS代碼添加64位支持時,發現nlist函數不適用於x86_64架構(64位iOS模擬器)。代碼調用nlist()適用於所有其他拱形(armv7,armv7s,arm64和i386),但對於x86_64無法成功構建,其中鏈接器無法在鏈接庫中找到該符號。架構x86_64未定義的符號:「_nlist」

它可以在Xcode中創建一個模板項目,轉載通過簡單地添加:

#import <mach-o/nlist.h> 

int testnlist() 
{ 
    struct nlist nl[2]; 
    bzero(&nl, sizeof(struct nlist) * 2); 
    return nlist("test", nl); 
} 

結果:

用於建築x86_64的未定義符號:
「_nlist」,從引用: ViewController.o中的_testnlist
ld:找不到架構x86_64的符號

使用iOS SDK:8.1構建iPhone 6模擬器,測試Xcode 6.1.1。

在我看來就像蘋果可能已經忘記了,包括一些模擬器對x86_64的內置共享庫的,但我也可能被忽視的東西愚蠢明顯...

+0

出於好奇,你有沒有試過' nlist_64'? –

+0

不,我沒有(我也沒有真正意識到它的存在),但我一定會試一試。 –

+0

啊,我明白了。 'nlist_64'是64位的符號表入口結構,但函數nlist()仍然缺失。 –

回答

0
you might want to try: 

#ifndef N_NLIST_DECLARED 
struct nlist 
{ 
    union 
    { 
     char *n_name; 
     struct nlist *n_next; 
     long n_strx; 
    } n_un; 
    unsigned char n_type; 
    char n_other; 
    short n_desc; 
    unsigned long n_value; 
}; 
#endif 

which I extracted from: 
<https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/android-4.1.2_r2/lib/gcc/x86_64-linux/4.6.x-google/include-fixed/linux/a.out.h> 

in that same header file, you will find lots of other things that 
will be 'gotcha's when moving to 64bit code 
+0

這不會有幫助,它是缺少函數nlist()的實現,而不是具有相同名稱的結構。 –

相關問題