0

我正在尝试添加 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)

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

任何帮助将不胜感激,因为我已经坚持了 3 天。

谢谢,威尔

4

1 回答 1

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

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

于 2011-06-02T21:11:13.187 回答