This guide was posted to the NestedVM mailing list by David Aubin. It covers obtaining and building NestedVM under XP with Cygwin.
Thanks David,
-Brian
Nested VM is an excellent tool to convert a C application to a Java
interpreted program or can also be used to convert a C program to a
Java Class. There are a few white papers available about the details,
but a summary of the process is:
- Build the c application for a mips based target (Mips, maps well to Java bytecode)
- Use either the Nested VM mips interpreter class or generate a java class from the mips output
Here's my environment:
- Windows XP machine
- Cygwin installed (www.cygwin.com)
- Eclipse installed (www.eclipse.org)
How to get started:
- Download nested vm from http://nestedvm.ibex.org/
- Untar it (use tar xzvf nestedvm-year-month-day.tgz)
- Get darcs
- you may also need darcs, if so then download it from here: http://darcs.net/DarcsWiki/CategoryBinaries
- unzip it (usually bunzip2 -d *.bz2 and then untar it)
- I personally just copied over the files for darcs into the /usr/bin/ directory
- Make sure the cygwin shell has the path to the java sdk bin directory
- In my case it was export
PATH=$PATH:/c/Program\ Files/Java/ jdk1.5.0_06/bin/
- run make in the nestedvm directory (Get a cup of coffee as it takes awhile)
- It is building the gcc and binutils for the mips cross compilier as well as the nested vm classgen classes
- These files are located in the ./upstream/build area
- Now take a look at the test files in nestedvm/src/tests directory
- In here are test.c files and java files
- Build one of the .c files with the cross compilier (hello.c) and name it hello.mips
- Example:
/c/temp/nestedvm/nestedvm-2007-01-12/upstream/build/gcc-obj/gcc/gcc-cross.exe -EB -O1 -Wall -c Hello.c -o hello.o /c/temp/nestedvm/nestedvm-2007-01-12/upstream/build/gcc-obj/gcc/gcc-cross.exe -EB -O1 hello.o -o hello.mips
- NOTE!!!! -O3 works.
- Also, use the -EB as -EL does not work on windows or just leave it off entirely
- You now have a mips based binary you can use with Nested VM:) Note, it will NOT run on windows's cygwin if you did it right:) Now let's integrate it with NestedVM!!!
- Use this simple java hello test to help you run your hello.mips
package tests;
//Include the nestedvm.Runtime
import org.ibex.nestedvm.Runtime;
public class hello {
public static void main(String[] args) {
//Place holder for command line arguments
String[] appArgs = new String[args.length + 1];
try {
//Application nmae
appArgs[0] = "./hello.mips";
//Fill in the rest of the command line arguments
for(int i=0;i<args.length;i++) appArgs[i+1] = args[i];
//Make a Runtime instantiation
final Runtime rt;
//Make a new mips interpreter
rt = new org.ibex.nestedvm.Interpreter("./hello.mips");
//Let er rip!
System.exit(rt.run(appArgs));
} catch(Exception e) {
System.err.println(e);
}
}
}
- Open up eclipse
- Make a new java project
- Point it to the nestedvm/src path (Copy over the nestedvm/upstream/build/classgen to the nestedvm/build to facilitate path locations)
- Put the above hello.java in the nestedvm/src/tests directory
- Put the hello.mips in the nestedvm/src directory
- Running out of eclipse defaults to the project main path, not the location of the java file you're testing that's why hello.mips not in the ... tests directory
- Right click on the hello.java in your new project and select run
- TADA!!!
- For those who wish to hava a java class generated rather than use an interpreter try this from Brian's quickstart: Quick Start Guide
-
java org.ibex.nestedvm.Compiler -outfile helloc.class Hello hello.mips
Enjoy! I know I have:)