user998996
user998996

Reputation: 1

Wrong Architecture when running executable from Xcode4 on UNIX

First of all, I'm very new to programming.

  1. I have a build a program using Xcode 4 on Snow Leopard. Architecture of the project is set to "Standard (32/64-bit intel)"

  2. Afterwards I have exported the executable file to a UNIX computer for running.

  3. ssh to that computer

  4. Typing ./programname in the terminal (Of the UNIX computer) gives the following response: Exec format error. Wrong Architecture.

The program runs just fine on my Mac laptop.

Upvotes: 0

Views: 1114

Answers (2)

Joachim Sauer
Joachim Sauer

Reputation: 308001

When you compile a program it will (*) be compiled for a specific platform and a specific operating system. It will also most likely be compiled against a specific set of libraries. Usually those parameters are exactly those of the computer doing the compilation (the other cases are called cross-compilation).

In other words: compiling a program on a Mac will produce a binary that runs only on a Mac (unless, again, you're doing cross-compilation). Your UNIX system (which UNIX, by the way?) has a different operating system, different libraries and probably even a different CPU architetcture.

Somewhat related: Apples advertised (or used to advertise) Mac OS X as a UNIX. While Mac OS X is certainly a UNIX-class operating system, that doesn't mean that it's binary compatible with every other UNIX-class OS out there.

* almost always, with the exception of systems designed to avoid this (e.g. Java)

Upvotes: 1

D.Shawley
D.Shawley

Reputation: 59553

Programs compiled by XCode will only run under MacOS X. Unless the "UNIX computer" in step 2 is running MacOS, the program will not be able to run.

Upvotes: 0

Related Questions