Objective-C 和 MetroWerks C/C++集成开发环境
我正在学习 Objective-C,我的朋友有一台真正的 Macintosh IIci,它使用 Mac System 7(特别是带有 68k 处理器的 7.5.5),并且我安装了 Metrowerks C/C++ IDE(我认为这是版本 1,但我不知道),但我没有测试过它,然后我想知道一件事:是否可以使用 NSObjects/Objects 和 AppKit 或类似的东西在 Objective-C 中进行开发?谢谢。
I'm learning Objective-C and my friend have a real Macintosh IIci, that uses a Mac System 7(specifically 7.5.5 with a 68k processor) and I've installed Metrowerks C/C++ IDE(I think it's the version 1, but I don't know), but i didn't tested it, then i want to know one thing: It's possible to develop in Objective-C using NSObjects/Objects and AppKit or something like this on it? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如斯蒂芬所说,简短的答案是否定的。但是,只是为了好玩,我开始思考你需要做什么才能真正实现这一目标。
1) 你必须让 gcc 在 68k 上运行(gcc 是使用 Objective-C 的编译器;你可能可以用 llvm 代替 gcc,但我们不要太疯狂)。这绝非易事。快速浏览一下最新的 gcc 版本并没有显示该平台的任何内容(毫不奇怪)。我不是 gcc 方面的专家,但我敢打赌它使用了 gcc 特定的扩展和现代 C,所以让它用现有的 68k 编译器进行编译可能是不可能的。
因此,第一步是向 gcc 添加 68k 后端。这将允许 gcc 吐出在 68k 上运行的代码。然后,您可以使用支持 68k 的 x86 版本的 gcc 来交叉编译一个新的 gcc 二进制文件,该二进制文件实际上可以在您的旧 Mac 上运行。
由于以前从未接触过 gcc,我怀疑这项任务需要我大约两三年的时间。也许更多。但这仍然不是不可能的。
2) 一旦你有了可以在 68k 机器上运行的现代版本的 gcc,你就可以用它来交叉编译 x86 或 PPC。 (由于您正在谈论 AppKit,因此您将永远无法在旧计算机上实际运行任何这些程序。所有测试都必须在更现代的计算机上进行。)您现在必须获取所有库和来自目标机器(PPC 或 x86 Mac)的 Cocoa/Foundation/AppKit/libc/etc 的标头,并将它们放在 68k 上的 gcc 可以找到的位置。这可能需要 6 个月的时间才能完成。但话又说回来,这不应该是不可能的。
但这可能不合法。据我所知,OS X(包含 Cocoa)和 Xcode 的许可协议不允许您随意将这些二进制文件移动到您想要的任何机器上。在执行此操作之前,您需要先咨询一位称职的律师,因为没有人愿意接受国际刑警组织的探访。
3)我想你现在已经完成了。您可以在 Mac IIci 上编写 Objective-C/Cocoa 代码,为 PPC 或 x86 Mac 进行编译,然后使用您最喜欢的方法将其发送到 OS X 机器(自 2005 年以来我才开始使用 Mac,所以我不这样做)甚至不知道 IIci 上的连接选项),并且测试和调试它相当痛苦。
此时,您可以访问在 PPC 或 x86 芯片上运行 OS X 的 Mac。您会想知道为什么不在这台机器上进行所有开发。由于您已经花费了几年的时间来设置 IIci 开发环境,因此购买旧的 PPC Mac 进行开发将便宜。
尽管如此,这可能是一个有趣的想法。如果你把它拉过来,它可能会让你登上 Reddit 的首页。 (不过,老实说,如果您只是追求这一点,那么在 YouTube 上伪造它会更容易。)
The short answer, as Stephen says, is no. But, just for fun, I started thinking about what you'd have to do to actually make that work.
1) You'd have to make gcc run on the 68k (gcc is the compiler that speaks Objective-C; you could probably substitute llvm for gcc, but let's not get too crazy). This is no mean feat. A quick look at the latest gcc builds does not show anything for that platform (unsurprisingly). I'm not an expert on gcc, but I bet it uses gcc-specific extensions and modern C so getting it to compile with an existing 68k compiler will probably be a non-starter.
So the first step for this will be adding an 68k back-end to gcc. This will allow gcc to spit out code that will run on a 68k. You could then use an x86 build of gcc with 68k support to cross-compile a new gcc binary that will actually run on your ancient Mac.
Having never messed with gcc before, I suspect that this task would take me about two-three years. Maybe more. but still, it's not impossible.
2) Once you've got a modern version of gcc that you can run on your 68k machine, you can use it to cross-compile for x86 or PPC. (Since you're talking about AppKit, you will never be able to actually RUN any of these programs on your old computer. All testing will have to take place on a more modern machine.) You now have to get all of the libraries and headers for Cocoa/Foundation/AppKit/libc/etc from your target machine (a PPC or x86 Mac) and put them somewhere that the gcc on your 68k can find. This will probably take a good 6 months of finagling to get right. But again, it shouldn't be impossible.
It might not be legal, though. As far as I know, the license agreements for OS X (which contains Cocoa) and Xcode will not let you move those binaries around willy-nilly to any machine you want. You would want to speak to a competent attorney before doing this as no one wants to get a visit from Interpol.
3) I think you're done at this point. You can write Objective-C/Cocoa code on your Mac IIci, compile it for a PPC or x86 Mac, ship it off to an OS X box using your favorite method (I've only been a Mac guy since 2005 so I don't even know the connectivity options on the IIci), and test and debug it rather painfully.
At this point, you have access to a Mac running OS X on either a PPC or x86 chip. And you will wonder why you don't just do all your development on THIS machine instead. And since you've spent a few years getting your IIci development environment set up, buying an old PPC Mac for development will be cheap.
Still, it could be a fun idea. It'd probably get you on the reddit front page if you pulled it over. (Though, honestly, it'd be easier to just fake it for YouTube if that's all you're after.)
简短的回答:不。
Objective-C 与 OS X 一起成为 Mac 开发的通用语言,在该计算机上市 10 年后,OS X 进入了测试版。 OS X 之前的系统的大多数开发都是使用 C 或 C++ 完成的。
如果没有 OS X,您将没有任何可链接的系统库或头文件,并且 Metrowerks 编译器将不知道有关 Objective-C 语法或 C 的运行时扩展的任何信息。
最重要的是,Objective-C框架是为 PowerPC(或现在的 Intel)mac 构建的,而该机器中的处理器使用旧的 68k 架构。
Short answer: no.
Objective-C became the lingua franca of mac development with OS X, which went into beta 10 years or so after that computer shipped. Most development for pre- OS X systems was done with C or C++.
Without OS X, you won't have any of the system libraries or headers to link against, and the Metrowerks compiler won't know anything about the Objective-C syntax or runtime extensions to C.
To top it off, the Objective-C frameworks are built for PowerPC (or now, Intel) macs, whereas the processor in that machine uses the older 68k architecture.
二十世纪九十年代初,gcc 仍在为 68k Amiga 编译,因此可能有机会让它在 68k Mac OS 上运行。我相信 Objective C 扩展至少从 90 年代初就可以用于 gcc 了。
另一种选择是使用 68k Linux。有一个 68k 的 Debian 4.0 (etch) 端口,并且当前正在努力恢复它,因此您可能会运行一个相当新的 gcc 版本。
还可以进行交叉编译。
同期的 C 环境(不知道是否有支持 Objective C)是 Think C(后来的 Symantec C++)和 Apple 的 Macintosh Programmers Workshop。理论上,您可以使用其中之一来编译 gcc 的 Objective C 支持版本。
gcc was still being compiled for 68k Amiga in the early noughties, so there might be some chance to get it working on 68k Mac OS. I believe Objective C extension were available from at least the early 90s for gcc.
Another option is to use 68k Linux. There is an port of Debian 4.0 (etch) for 68k, and a current effort to revive it, so you could likely get a fairly recent version of gcc running.
There is also the possibility to cross compile.
The contemporaneous C environments (no idea if any had supporting Objective C) were Think C (later Symantec C++) and Apple's Macintosh Programmers Workshop. In theory, you might get one of these to compile an objective C supporting version of gcc.
不,据我所知,他们不可能太老了。
No, it's not possible they are just too old to my knowledge.