I originally started this blog with the idea of building an Android application and recording my experience. School, work and other activities have sent this in a totally different direction. I still plan on recording my development experiences here, the actual topics, though, have changed.
On to the reason for this post. I was recently asked if I would be interested in doing some work writing an interface to a financial trading system. The gist of the project is this - write an application that polls the market data specified, runs an algorithm against it, and notifies the user if the algorithm meets a certain threshold. The makers of the software have conveniently supplied an API to read their data streams. In fact, they have supplied an API for C++, Java, and POSIX. Being a native Java developer, you would think that I would immediately go for that solution to the problem. The truth is, if I end up doing this, that will be my likely path.
When I got to thinking about the problem domain, however, I thought I should be prepared for a different build. First off, consider the basic description - get market data, perform analysis, give result. This is clearly intended to give the user the proper information to make a decision about a trade, and then act on it. Clearly, the faster the application works, the better. Now consider an application running in the JVM. Basic operations between Java and other languages, given the high quality JIT implementations these days, is minimal. I wouldn't expect to see a significant performance hit using Java as opposed to C++. The second consideration, though, is garbage collection. If I implement the system poorly, there may be periodic delays due to garbage collection. Heck, if I implement it correctly there may be delays. Now I have to consider whether I think this will actually be an issue, and the answer is, probably not. I can take actions to minimize GC and optimize the return of the results. This got me thinking, though. It would be nice to be able to write this in C++. So I decided to make sure that I could.
The Development Stack
After some brief research I decided to go with the Qt library on NetBeans. You can learn more about Qt here. Why Qt and NetBeans? Well Qt is an LGPL, cross platform component library with a neat Visual editor. NetBeans is a high-quality Open Source IDE, with a lot of support for C++. I could have gone with Eclipse, which is my primary IDE, but NetBeans has always had a leg up on this type of development in my book.
NetBeans even has a nice tutorial on how to configure and set up a Qt project. Too bad it is no longer accurate (Nod to Steve, "Yes this is another case of an OS project documentation being out-of-date"). Here is what I found:
- The tutorial instructs you to install mingw, qt and msys separately. This is not needed if you are using 4.6.2. In fact, this won't work.
- This post suggests that Qt changed the version of the compiler they use in the latest bundle, and that they include mingw with the distribution.
So, here is my short list of steps you need to follow to get Qt working with NetBeans:
- Make sure you have the JDK and NetBeans installed
- Make sure you have NetBeans C/C++ plugin
- Install msys1.0 (As easy as following the defaults in the installer)
- Get the Qt installer, Full version. Follow the defaults (The NetBeans tutorial says to only download the Qt libraries)
- Go toTools->Options, C/C++.
- Click Add...
- Select the Qt mingw installation as your base directory (mine is at: c:\Qt\2010.02.1\mingw\bin
- Select mingw as your tool collection family. Your collection configuration should look like the screen shot below
Build and Run
You should now be able to build and run the sample from the NetBeans tutorial. Remember to make sure that your Qt Tool collection is the collection used for the build.