ChrisCS
ChrisCS

Reputation: 13

C Program (in OS X) - file was built for archive which is not the architecture being linked (x86_64)

I have an assignment in which I have to use a given source code with an included library, namely, libdb_factory.a and libdb_factory32.a (they gave us both x86_64 and ie386 versions).

The first hint of something going wrong is that, when executing lipo -info on any of them, I get this:

fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: archive 
with no architecture specification: libdb_factory32.a 
(can't determine architecture for it)

Whenever I try to compile the code with make, I get the following:

Compiling
-n
-n Concurent example [..
ld: warning: ignoring file ./lib//libdb_factory.a, file was built for
 archive which is not the architecture being linked (x86_64): ./lib//libdb_factory.a
Undefined symbols for architecture x86_64:
  "_db_factory_create_element", referenced from:
  _insert_create in factory-0aefa1.o
  "_db_factory_get_element_name", referenced from:
      _transporter in factory-0aefa1.o
  "_db_factory_get_ready_state", referenced from:
      _transporter in factory-0aefa1.o
  "_db_factory_get_stock", referenced from:
      _transporter in factory-0aefa1.o
      _receiver in factory-0aefa1.o
      _insert_update in factory-0aefa1.o
  "_db_factory_init", referenced from:
      _init_factory in factory-0aefa1.o
  "_db_factory_update_stock", referenced from:
      _transporter in factory-0aefa1.o
      _insert_update in factory-0aefa1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

The referenced functions are part of the library which is ignored. I don't have access to a linux machine (unless I use a virtual machine) but I know it works alright on ubuntu 14.04.

Does anyone know what can I do? Any help would be kind appreciated.

Upvotes: 1

Views: 816

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

Static libraries (i.e. the object files within them) compiled for Linux cannot be used on OSX.

The only thing you can do is:

  1. Get access to the source and create OSX versions of the libraries.
  2. Use a virtual machine to build the code.

Upvotes: 3

Related Questions