Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top