2011-06-02 63 views
0

我嘗試添加TCMPortMapper時(http://code.google.com/p/tcmportmapper/)錯誤導入框架的Objective-C

我已經鏈接的框架的構建階段,並試圖運行示例代碼:

#import <Foundation/Foundation.h> 
#import <TCMPortMapper/TCMPortMapper.h> 
int main (int argc, const char * argv[]) 

{ 

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
    TCMPortMapper *pm = [TCMPortMapper sharedInstance]; 
    [pm addPortMapping: 
    [TCMPortMapping portMappingWithLocalPort:13478 
         desiredExternalPort:4321 
          transportProtocol:TCMPortMappingTransportProtocolTCP 
            userInfo:nil]]; 
    [pm start]; 

    [pool drain]; 
    return 0; 
} 

,但我得到的錯誤:

ld: warning: ignoring file /Applications/TCMPortMapper.framework/TCMPortMapper, missing   required  
architecture x86_64 in file 
Undefined symbols for architecture x86_64: 
    "_OBJC_CLASS_$_TCMPortMapper", referenced from: 
     objc-class-ref in main.o 
    "_OBJC_CLASS_$_TCMPortMapping", referenced from: 
     objc-class-ref in main.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

即時猜測它是與框架,而不是我。但是我花了很多時間搜索 ,除了它可能是32位和64位模式以外,沒有多少發現。

任何幫助將非常感激,因爲我一直堅持這個爲期3天。

感謝, 威爾

回答

1

是否使用TCPPortMapper的二進制版本?它沒有x86_64可執行文件。

$ file TCMPortMapper.framework/TCMPortMapper 
TCMPortMapper.framework/TCMPortMapper: Mach-O universal binary with 2 architectures 
TCMPortMapper.framework/TCMPortMapper (for architecture ppc): Mach-O dynamically linked shared library ppc 
TCMPortMapper.framework/TCMPortMapper (for architecture i386): Mach-O dynamically linked shared library i386 

添加GCC 「-m32」 或 「-arch i386的」 選項CFLAGS和LDFLAGS,或建立自己TCPPortMapper爲x86_64的牌坊。

+1

很可能OP已經在構建i386和x86_64。 OP可以從構建設置中刪除x86_64體系結構,強制他們的機器運行i386體系結構,但構建i386/x86_64通用版本的框架將是更好的解決方案。 – 2011-06-02 21:21:11

+0

還將部署目標設置爲10.5或10.4會更好。 – 2011-06-02 21:25:11