macOSX,C语言和嵌入式Lua。

好的,我们现在有:

一个用 C 语言编写的程序,在 Linux 和 MacOSX(leopard)上编译和运行都没有问题。

今天,我嵌入了 lua 代码。Linux:从源代码编译了 lua 5.1。一切都能够编译和运行,没有任何问题。Macos:编译了相同的 lua 5.1 包。

链接选项是 --llua。

开始编译,结果出现了一个错误:

CC=gcc-4.0 make

ld: warning: in /usr/local/lib/liblua.a, file is not of required architecture

我也试过重新安装,完全删除,并从 macports 安装。但还是出现同样的问题。

那么有没有什么解决方法呢?

原文链接 https://stackoverflow.com/questions/10173423

点赞
stackoverflow用户2811
stackoverflow用户2811

错误信息 "file is not of required architecture" 提示你试图混合使用架构。

检查 /usr/local/lib/liblua.a 的架构,并确保其与正在构建的对象的架构匹配。

例如:如果我们有一个 i386 对象:

==== cat fun.c ====
#include <stdio.h>
void fun()
{
    printf("%s", "foobar\n");
}
gcc -arch i386 -c fun.c -o fun.o

如果我们试图在编译 x86_64 对象时使用它(在 Mac OS X 中是默认架构):

===== cat test.c ==
extern void fun();
int main()
{
    fun();
}

我们会得到:

$ gcc test.c fun.o
ld: warning: ignoring file fun.o, file was built for i386 which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
  "_fun", referenced from:
      _main in ccXVCQhG.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
2012-04-20 09:55:45