【问题标题】:Error when importing framework objective-c导入框架objective-c时出错
【发布时间】:2011-09-07 09:24:54
【问题描述】:

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

谢谢, 会

【问题讨论】:

    标签: objective-c macos frameworks mac-frameworks


    【解决方案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 架构自行构建 TCPPortMapper。

    【讨论】:

    • 很可能 OP 已经在构建 i386 和 x86_64。 OP 可以从构建设置中删除 x86_64 架构,以强制他们的机器运行 i386 架构,但是构建一个 i386/x86_64 通用版本的框架会是更好的解决方案。
    • 同样设置部署目标为 10.5 或 10.4 会更好。
    猜你喜欢
    • 1970-01-01
    • 2011-11-03
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 2015-09-14
    • 1970-01-01
    • 2018-06-09
    • 1970-01-01
    相关资源
    最近更新 更多