在 UNIX 上从 Xcode4 运行可执行文件时架构错误
首先,我对编程很陌生。
我在 Snow Leopard 上使用 Xcode 4 构建了一个程序。 该项目的体系结构设置为“标准(32/64 位英特尔)”
然后我将可执行文件导出到UNIX计算机上运行。
ssh 到该计算机
在终端(UNIX 计算机)中键入
./programname
会给出以下响应: 执行格式错误。错误的架构。
该程序在我的 Mac 笔记本电脑上运行得很好。
First of all, I'm very new to programming.
I have a build a program using Xcode 4 on Snow Leopard.
Architecture of the project is set to "Standard (32/64-bit intel)"Afterwards I have exported the executable file to a UNIX computer for running.
ssh to that computer
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您编译程序时,它将 (*) 针对特定平台和特定操作系统进行编译。它还很可能针对一组特定的库进行编译。 通常这些参数正是进行编译的计算机的参数(其他情况称为交叉编译)。
换句话说:在 Mac 上编译程序将生成仅在 Mac 上运行的二进制文件(除非您再次进行交叉编译)。您的 UNIX 系统(顺便问一下,是哪个 UNIX?)有不同的操作系统、不同的库,甚至可能有不同的 CPU 架构。
有点相关:苹果公司宣传(或用来宣传)Mac OS X 是 UNIX。虽然 Mac OS X 无疑是一个 UNIX 类操作系统,但这并不意味着它与其他所有 UNIX 类操作系统都是二进制兼容的。
* 几乎总是如此,除了旨在避免这种情况的系统(例如 Java)
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)
XCode编译的程序只能在MacOS X下运行。除非步骤2中的“UNIX计算机”运行的是MacOS,否则程序将无法运行。
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.