xcode 的 c++ 可执行产品项目

发布于 2024-09-16 14:15:52 字数 303 浏览 4 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

避讳 2024-09-23 14:15:52

OS X 基于 Unix,它使用纯二进制文件(即没有文件扩展名)作为可执行文件。如果它们具有一定的“可执行权限”,则可以双击它们以作为可执行文件运行,或从命令行运行。但是,此权限不能通过电子邮件发送 - 它是文件系统本身内的元数据,从安全角度来看这是有意义的(您不希望垃圾邮件发送者通过电子邮件向您发送可执行病毒,对吗?)。因此,当收件人收到二进制文件时,他们需要对其运行以下命令行命令,假设“hanoi”是二进制文件的名称:

chmod +x /path/to/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:

chmod +x /path/to/hanoi

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!

以歌曲疗慰 2024-09-23 14:15:52

在 Mac 上,跨同一操作系统的不同版本共享应用程序可能非常困难(至少就个人经验而言)。

为了能够以最少的努力共享您的应用程序,您需要弄清楚:

  • 这是什么项目类型?您是否使用图像等资源?
  • 您的朋友使用什么版本的操作系统?如果它们不在 Mac 上,那么你就不走运了(或者你必须为他们的操作系统重新编译)。
  • 如果他们运行 Mac,请检查您是否具有相同的操作系统版本,如果您在 Leopard 上开发,而有人在 SnowLeopard 上运行,您的应用程序可能会失败。 (我还在 Mac OS 10.5.4 和 10.5.3 之间遇到了问题,所以请祈祷。)
  • 检查一下您正在运行的硬件类型。您是只为您的硬件(例如 MacIntel)构建还是正在创建通用二进制文件?
  • 确保所有资源都打包到您的应用程序包中。确保您的应用程序仅使用相对路径。
  • 检查您是否没有写入特殊文件夹(即,如果需要,仅使用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:

  • What project type is this? Are you using any resources like images etc?
  • What version of the OS your friends are using? If they are not on the Mac, you're out of luck (or you'll have to recompile for their OS-es).
  • If they run Mac, check out that you have the same OS versions, if you have developed on Leopard and someone's running on SnowLeopard your application might simply fail. (I also ran into issues between Mac OS 10.5.4 and 10.5.3 so keep your fingers crossed.)
  • Check out what sort of hardware you are running. Are you building for your hardware (say, MacIntel) only or are you creating an Universal Binary?
  • Make sure that all resources are packaged into your application bundle. Make sure your application uses only relative paths.
  • Check if you are not writing to special folders (i.e. use only 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).

香橙ぽ 2024-09-23 14:15:52

如果您对命令行工具而不是可双击的应用程序感到满意,那么将其压缩并将其附加到电子邮件中就足够了。如果您的发送对象可能使用基于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文