为 JVM 编译 C++

2022-01-17 00:00:00 compiler-construction c++ java

在编译 C++ 时,您当然要为要编译的目标平台使用编译器.是否有针对 JVM 的 C++ 编译器(因此不是使用 Java本机"接口,而是将 C++ 代码编译为 Java 字节码)?

When compiling C++ you of course use a compiler for the target platform you want to compile for. Is there a C++ compiler that targets the JVM (so instead of using the Java "native" interface C++ code is compiled to Java byte code)?

推荐答案

NestedVM 为 Java 字节码提供二进制翻译.这是通过将 GCC 编译为 MIPS 二进制文件来完成的,然后将其转换为 Java 类文件.因此,任何用 C、C++、Fortran 或 GCC 支持的任何其他语言编写的应用程序都可以在 100% 纯 Java 中运行,而无需更改源代码.

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

相关文章