目前我在使用Xcode 4.0.2的Mac OS X 10.6.7上遇到了弱链接问题.
robin@chameleon:/tmp/o$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Run Code Online (Sandbox Code Playgroud)
正如文档http://developer.apple.com/library/mac/#technotes/tn2064/_index.html所说,我们可以使用gcc 属性((weak_import))作为弱链接符号.但是,以下示例代码始终抛出编译错误.如下:
weak.c:
#include <stdlib.h>
#include <stdio.h>
extern int SayHello() __attribute__((weak));
int main()
{
int result;
if (SayHello!=NULL)
{
printf("SayHello is present!\n");
result=SayHello();
}
else
printf("SayHello is not present!\n");
}
Run Code Online (Sandbox Code Playgroud)
错误消息如下:
robin@chameleon:/tmp/o$ gcc weak.c
Undefined symbols for architecture x86_64:
"_f", referenced from:
_main in cceOf2wN.o
(maybe you meant: __dyld_func_lookup)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned …Run Code Online (Sandbox Code Playgroud) 为了在Mac OS X(10.6.7)上构建64位PicoLisp,我似乎遇到了OSX Dev的问题.工具GNU汇编程序('as'),版本1.38.我的Xcode是版本3.2.4.我生成的(生成的)x86-64.darwin.base.s中导致问题的行通常如下所示:
call foo@plt
Run Code Online (Sandbox Code Playgroud)
...他们给我这样的错误信息:
x86-64.darwin.base.s:41694:junk `@plt' after expression
Run Code Online (Sandbox Code Playgroud)
在Linux和SunOS上,64位PicoLisp构建没有问题.这些平台可能具有更强大(更新)版本的GNU汇编程序.我不知道新的GNU汇编程序是否适用于OSX/Darwin ...还是可以有其他解决方案?
如果你想在OSX/Darwin上自己尝试一下,我可以给你一些需要的文件.