2011-06-02 64 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