导入框架objective-c时出错

时间:2011-06-02 20:48:32

标签: objective-c macos frameworks mac-frameworks

我正在尝试添加TCMPortMapper(http://code.google.com/p/tcmportmapper/)

我已经在构建阶段链接了框架,并尝试运行示例代码:

#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)

我猜它与框架有关,而不是我。但我花了很多时间在Google上搜索 除了它可能是32位和64位模式之外,没有多少出现过。

任何帮助都会非常感激,因为我已经坚持了3天。

谢谢, 将

1 个答案:

答案 0 :(得分:1)

您使用的是TCPPortMapper的二进制版本吗?它没有x86_64 arch可执行文件。

$ 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

向CFLAGS和LDFLAGS添加GCC“-m32”或“-arch i386”选项,或者为x86_64 arch自己构建TCPPortMapper。