1
votes

Ok, what we have:

Program written on C which compiling and running without problems in Linux and MacOSX (leopard). I embedded lua code today. Linux: compiled lua 5.1 from source. Everything works and compiles without any problems. Macos: compiled the same lua 5.1 package.

Linked with --llua.

Started compile and got an error:

CC=gcc-4.0 make

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

Also tried reinstall, complete remove and installing from macports. The same.

So is there any fix for that?

1
_Lua_Call is not a symbol in the Lua C API. - lhf
Cool, but its compiling and its working, the main problem with macos error ld: warning: in /usr/local/lib/liblua.a, file is not of required architecture - TotallyStuck
If you have compiled and installed Lua from source downloaded from lua.org this should not happen. - lhf
Yes and also the same error with Lua from macports - TotallyStuck
See Luiz's (one of Lua's authors) comment above. Lua's source is pure ANSI C with no external dependencies. It's incredibly easy to build. Rather than lying on a library built by someone else, just build it yourself or add the source to your project. It's beyond trivial on a Unix-like system. - Mud

1 Answers

0
votes

The error "file is not of required architecture" hints to the fact that you're trying to mix architectures.

Check the architecture of the /usr/local/lib/liblua.a and make sure it matches the architecture or the object you're trying to build.

E.g.

We have a i386 object:

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

if we try to use it when compiling a x86_64 object (default architecture in Mac OS X):

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

we get:

$ 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