Thursday, December 29, 2011

Building QtSpim

I use QtSpim, a MIPS simulator for the Computer Organization and Architecture class I teach. Jim Larus at Microsoft Research originally devloped SPIM at the University of Wisconsin and graciously maintains it, and has recently ported it to use Qt. The 64-bit debian package uses a newer version of Qt than I have installed in my labs (Ubuntu 10.04, which is the most recent LTS as of this writing). Rebuilding QtSpim in QtCreator and distributing the Qt shared libraries along with the executable fixes things.
  1. Get yourself a copy of Qt Creator and SDK from Nokia.
  2. Download the SPIM source code. Probably the easiest thing is to install subversion and check the code out:
    svn co https://spimsimulator.svn.sourceforge.net/svnroot/spimsimulator spimsimulator
    
    This creates a directory named spimsimulator. You can also download the tarball at that site and unpack it.
  3. In QtCreator open the project by opening the file spimsimulator/QtSpim/QtSpim.pro
  4. Build a release version of the project in Qt Creator (self explanatory)
  5. The executable is sitting in QtSpim-build-desktop/QtSpim.
  6. QtSpim uses two shared libraries from the Qt SDK. These are libQtGui.so.4 and libQtCore.so.4. Be careful, both of these are probably just links to the real shared objects sitting in the same directory.
  7. In my case I needed to distribute the executable and the two shared libraries to a lab so I copied them to a global place (in my case /usr/local on each machine). I also wrote a simple script to set LD_LIBRARY_PATH to pick up the correct Qt libraries and execute the QtSpim executable. The other option is have users manually set LD_LIBRARY_PATH in their .bashrc.

Tuesday, December 27, 2011

Installing eclipse plugins for multiple users

These notes are primarily for myself because I can never freaking remember how to do this and I always lose my handwritten chicken scratch. If you happen to run across them and find them useful, then cool.

When an eclipse user installs plugins through Help Install New Software it puts the plugins in the user's local hierarchy. I had recently installed PDT, the PHP Development Toolkit for a single user and wanted to distribute it to a lab environment for multiple users.

  1. Fire up eclipse and make sure a valid repository is set at
    Window  Preferences  Install/Update  Available Software Sites
    
    Since I am running 3.7 (Indigo) I set it to
    http://download.eclipse.org/releases/indigo
  2. In the eclipse GUI install the plugin you want as a single user. For me this was
    Help  Install New Software  Programming Languages  PHP Development Tools
    
  3. Eclipse installs plugins in two directories features and plugins at ~/.eclipse/org.eclipse.yaddayadda/ where yaddayadda is some version specific string. For me this was platform_3.7.0_185596441.
  4. Go to that directory (the parent of features and plugins) and tar/gzip them up
    tar cf plugins.tar features plugins; gzip plugins.tar
  5. Distribute the file plugins.tar.gz to each machine or put it in a shared location. I put it in my web hierarchy and did a wget from each machine using clusterssh.
  6. Unzip it
    tar xzvf plugins.tar.gz
  7. Copy the contents of each folder to the location where eclipse is installed. For me this is in /usr/local/eclipse/ and then features and plugins. For me this was
    sudo cp -r features/* /usr/local/eclipse/features/
    sudo cp -r plugins/* /usr/local/eclipse/plugins/
    
  8. Make sure permissions are read for everyone. So I had to
    sudo chmod -R o+r *
    inside of the shared features and plugins directories.

Friday, December 2, 2011

MathJax in Blogger

Playing around getting MathJax to work in blogger. Below is the spherical law of cosines. It was getting cut off at the right so I had to break it up into two pieces. A bit ugly.

\[ d = \cos^{-1}(\sin(lat_1)\sin(lat_2) + \] \[ \cos(lat_1)\cos(lat_2)\cos(lon_2-lon_1))R \]

And some other mess that I got from here. \[ z \left( 1 \ +\ \sqrt{\omega_{i+1} + \zeta -\frac{x+1}{\Theta +1} y + 1} \ \right) \ \ \ =\ \ \ 1 \]

And this is from the MathJax main page.

\[ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} \]

So I think we can say it works. Right click on any equation and Show Source to see the LaTex.

So to use MathJax in a blog post you need to edit a post as HTML and insert the Javascript below.

<script src="http://cdn.mathjax.org/mathjax/1.1-latest/MathJax.js">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
    tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
  });
</script> 

Now add LaTex equations in your HTML using \[ latex-equation \].