Recent Changes - Search:

Software

Wiki Docs

CygwinBuildingGuide

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:

  1. Build the c application for a mips based target (Mips, maps well to Java bytecode)
  2. Use either the Nested VM mips interpreter class or generate a java class from the mips output

Here's my environment:

  1. Windows XP machine
  2. Cygwin installed (www.cygwin.com)
  3. Eclipse installed (www.eclipse.org)

How to get started:

  1. Download nested vm from http://nestedvm.ibex.org/
  2. Untar it (use tar xzvf nestedvm-year-month-day.tgz)
  3. Get darcs
    1. you may also need darcs, if so then download it from here: http://darcs.net/DarcsWiki/CategoryBinaries
    2. unzip it (usually bunzip2 -d *.bz2 and then untar it)
    3. I personally just copied over the files for darcs into the /usr/bin/ directory
  4. Make sure the cygwin shell has the path to the java sdk bin directory
    1. In my case it was export PATH=$PATH:/c/Program\ Files/Java/ jdk1.5.0_06/bin/
  5. run make in the nestedvm directory (Get a cup of coffee as it takes awhile)
    1. It is building the gcc and binutils for the mips cross compilier as well as the nested vm classgen classes
    2. These files are located in the ./upstream/build area
  6. Now take a look at the test files in nestedvm/src/tests directory
    1. In here are test.c files and java files
    2. Build one of the .c files with the cross compilier (hello.c) and name it hello.mips
      1. 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
    3. NOTE!!!! -O3 works.
    4. Also, use the -EB as -EL does not work on windows or just leave it off entirely
  7. 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!!!
    1. 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);
              }
      	}
      }
      
    2. Open up eclipse
      1. Make a new java project
      2. Point it to the nestedvm/src path (Copy over the nestedvm/upstream/build/classgen to the nestedvm/build to facilitate path locations)
      3. Put the above hello.java in the nestedvm/src/tests directory
      4. Put the hello.mips in the nestedvm/src directory
        1. 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
      5. Right click on the hello.java in your new project and select run
      6. TADA!!!
  8. For those who wish to hava a java class generated rather than use an interpreter try this from Brian's quickstart: Quick Start Guide
    1. java org.ibex.nestedvm.Compiler -outfile helloc.class Hello hello.mips

Enjoy! I know I have:)

Edit - History - Print - Recent Changes - Search
Page last modified on October 30, 2007, at 04:45 PM EDT