Objective-C编译成本机代码还是字节代码?

时间:2022-09-07 09:38:30

On OS X, does Objective-C compile to native code or byte-code?

在OS X上,Objective-C编译为本机代码还是字节代码?

Can Objective-C programs be compiled on Linux?

Objective-C程序可以在Linux上编译吗?

4 个解决方案

#1


19  

Objective-C is compiled to native code by either GCC or LLVM[*]. You can compile ObjC programs on Linux (the generic GCC will happily support ObjC, though it uses a different runtime library than either of the Apple ones). For a cross-platform API similar to Cocoa (i.e. derived from Cocoa) which will happily work on Linux and let you port some code between OS X and Linux, check out GNUstep: http://www.gnustep.org

Objective-C由GCC或LLVM[*]编译成本机代码。您可以在Linux上编译ObjC程序(通用的GCC很乐意支持ObjC,尽管它使用的运行时库与苹果的库不同)。对于类似于Cocoa的跨平台API(即源自Cocoa),它可以在Linux上工作,并允许您在OS X和Linux之间移植一些代码,请查看GNUstep: http://www.gnustep.org

[*]In fact, LLVM internally compiles the Objective-C to an internal bitcode representation, then to code for the target machine, so perhaps the answer is "both"…

事实上,LLVM在内部将Objective-C编译为一个内部位码表示,然后再编译为目标机器编写代码,所以答案可能是“both”……

#2


7  

It's native.

这是本地的。

There is GNUstep which an Open Source implementation of the NeXT OpenStep specification written in Objective-C. Their implementation of the Cocoa API is not a direct match so a direct compilation without porting is not possible.

GNUstep是用Objective-C编写的下一个OpenStep规范的开源实现。它们对Cocoa API的实现不是直接匹配的,所以不需要移植就可以直接编译。

#3


4  

Yes, Objective-C compiles to machine code.

是的,Objective-C编译为机器代码。

Objective-C compilers exist for Linux, but Cocoa is an OS X-only technology. I've heard of an open replacement called GNUstep, but don't know much about it.

Objective-C编译器适用于Linux,但是Cocoa都是OS X-only技术。我听说过一种叫做GNUstep的开放式替代品,但我对它知之甚少。

#4


2  

Objective-C is a variant of C. It compiles to native code.

Objective-C是c的变体,它编译为本机代码。

#1


19  

Objective-C is compiled to native code by either GCC or LLVM[*]. You can compile ObjC programs on Linux (the generic GCC will happily support ObjC, though it uses a different runtime library than either of the Apple ones). For a cross-platform API similar to Cocoa (i.e. derived from Cocoa) which will happily work on Linux and let you port some code between OS X and Linux, check out GNUstep: http://www.gnustep.org

Objective-C由GCC或LLVM[*]编译成本机代码。您可以在Linux上编译ObjC程序(通用的GCC很乐意支持ObjC,尽管它使用的运行时库与苹果的库不同)。对于类似于Cocoa的跨平台API(即源自Cocoa),它可以在Linux上工作,并允许您在OS X和Linux之间移植一些代码,请查看GNUstep: http://www.gnustep.org

[*]In fact, LLVM internally compiles the Objective-C to an internal bitcode representation, then to code for the target machine, so perhaps the answer is "both"…

事实上,LLVM在内部将Objective-C编译为一个内部位码表示,然后再编译为目标机器编写代码,所以答案可能是“both”……

#2


7  

It's native.

这是本地的。

There is GNUstep which an Open Source implementation of the NeXT OpenStep specification written in Objective-C. Their implementation of the Cocoa API is not a direct match so a direct compilation without porting is not possible.

GNUstep是用Objective-C编写的下一个OpenStep规范的开源实现。它们对Cocoa API的实现不是直接匹配的,所以不需要移植就可以直接编译。

#3


4  

Yes, Objective-C compiles to machine code.

是的,Objective-C编译为机器代码。

Objective-C compilers exist for Linux, but Cocoa is an OS X-only technology. I've heard of an open replacement called GNUstep, but don't know much about it.

Objective-C编译器适用于Linux,但是Cocoa都是OS X-only技术。我听说过一种叫做GNUstep的开放式替代品,但我对它知之甚少。

#4


2  

Objective-C is a variant of C. It compiles to native code.

Objective-C是c的变体,它编译为本机代码。