xcode 的 c++ 可执行产品项目
我使用 xcode 的 C++ 命令行工具完成了游戏“河内塔”的简单数字版本。由于习惯了 borland 和 Visual-C 等 PC 编译器,我尝试通过电子邮件与其他人“共享”游戏,只需附加由 xcode 构建的可执行产品即可。然而,接收者无法运行该程序,因为它以不同的格式显示——听起来通常是机器代码。
经过一番广泛的搜索后,我意识到在 xcode 的 IDE 中构建项目的复杂性以及构建设置/目标的变化等。
有人知道如何构建一个独立的 c++ 可执行文件以供普遍运行吗?对于这个游戏,我不会离开 STL 库。我将非常感谢任何帮助。
谢谢
I've completed a simple numbers-version of the game "Towers of Hanoi" using xcode's command line tool in C++. Being accustomed to PC compilers like borland's and visual-c, I've attempted to "share" the game with others via e-mail by simply attaching the executable product built by xcode. However, the recipients can't run the program as it shows up in a different format - usually machine code, it sounds like.
After a bit of extensive searching, I'm realizing the complexity of building projects within xcode's IDE and the variations on the build settings/ targets, etc.
Anyone know how to build a self-contained c++ executable to be universally run? I don't go outside the STL library for this game. I'd greatly appreciate any help.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
OS X 基于 Unix,它使用纯二进制文件(即没有文件扩展名)作为可执行文件。如果它们具有一定的“可执行权限”,则可以双击它们以作为可执行文件运行,或从命令行运行。但是,此权限不能通过电子邮件发送 - 它是文件系统本身内的元数据,从安全角度来看这是有意义的(您不希望垃圾邮件发送者通过电子邮件向您发送可执行病毒,对吗?)。因此,当收件人收到二进制文件时,他们需要对其运行以下命令行命令,假设“hanoi”是二进制文件的名称:
如果您确实想将其打包为可立即双击的应用程序,则您可以需要给它一个本机 UI 并将其打包为 .app,然后将该 .app(实际上是带有 .app 扩展名的文件夹)放入存档中进行分发。很抱歉,如果这比您希望的要多。希望这有帮助!
OS X is based on Unix, which uses plain binary files (i.e. no filename extension) as executables. If they have a certain "executable permission," they can be double-clicked to be run as executables, or run from the command line. However, this permission can't be sent over email - it's metadata within the file system itself, and this makes sense from a security standpoint (you wouldn't want spammers sending you executable viruses over email right?). So when the recipient receives the binary, they'll need to run the following command line command on it, assuming "hanoi" is the name of the binary file:
If you really want to package it as an instantly double-clickable application, you'll need to give it a native UI and package it as a .app, then put that .app (which is actually a folder with the .app extension) in an archive to distribute. Sorry if that's more work than you were hoping for. Hope this helps!
在 Mac 上,跨同一操作系统的不同版本共享应用程序可能非常困难(至少就个人经验而言)。
为了能够以最少的努力共享您的应用程序,您需要弄清楚:
temp
和/或可字写的位置)。我希望我可以给出更详细/切中要害的答复,但不幸的是,您必须自己找出一些答案(没有有关您收到的错误的任何其他具体信息)。
Sharing applications across dot releases of the same OS can be notoriously difficult on the Mac (at least, as far as personal experience goes).
In order to be able to share your application with the least amount of effort, you will need to figure out:
temp
and/or word-writable locations, if you need to).I wish I could give a more detailed/to the point reply but unfortunately you'll have to figure out some of the answers yourself (without any other specific information about the error you are getting).
如果您对命令行工具而不是可双击的应用程序感到满意,那么将其压缩并将其附加到电子邮件中就足够了。如果您的发送对象可能使用基于 PowerPC 的 Mac,请务必构建通用版本。哦,并将部署目标设置为任何收件人可能使用的最低操作系统。
If you're satisfied with a command line tool rather than a double-clickable app, it should suffice to zip it and attach that to the e-mail. Be sure to build universal if anyone you're sending to might be using a PowerPC-based Mac. Oh, and set the deployment target to the minimum OS that any recipient might be using.