Archive for March, 2009

gmock, gtest, ubuntu and C/C++

Sunday, March 29th, 2009

 puzzle

There are a few projects that I have wanted to do for a very long time, some of which are products and some of which are tools. Over the weekend I thought I would use some very rare free time from looking after my twin son’s to look at using C/C++, google gtest and gmock to assess the “cost” to me of using them for one of these projects. I remember a time when testing in the C/C++ world was somewhat of a very manual task and one that didn’t get a lot of attention so I’m excited to be using gtest and gmock in with this language, but I’m not sure when my next free time is likely to be.

I downloaded gtest and followed the build instructions but the didn’t work but this may have just been my reading of the instructions, however, what follows are the steps I used to get gtest and gmock installed. What I have left to do now is create a C/C++ project and drive the first class forward with tests and mocks.

For Ubuntu 8.10 and gcc 4.3.2

  1. download gtest and unzip into a folder
  2. cd to that folder
  3. cd into the ’src’ folder
  4. make a ‘build’ folder
  5. cd into the ‘build’ folder
  6. run the command ‘../../configure
  7. run the command ‘make’
  8. run the command ‘make check’
  9. run ’sudo make install’ which will put the libraries, headers and executables in ‘/usr/local’
  10. add ‘/usr/local/lib’ to your LD_LIBRARY_PATH and optionally add ‘usr/local/bin’ to the PATH
  11. download gmock and unzip into a folder
  12. cd to that folder
  13. make a ‘build’ folder
  14. cd into the ‘build’ folder
  15. run the command ‘../configure CC=gcc-4 CXX=g++-4′
  16. run the command ‘make’
  17. run the command ‘make check’
  18. run ’sudo make install’ which will put the libraries, headers and executables in ‘/usr/local’

The above worked for me and all the tests ran (make check) without error.  Note that I have added the ‘ CC=gcc-4 CXX=g++-4′ arguments to the configure step for gmock which are required in the latest cygwin release to ensure gcc version 4 is used. I don’t use these flags under linux and I don’t use them for gtest.

If you are wondering what it is I am building with C/C++, gtest and gmock then drop me an email or catch up with me at the next Melbourne Patterns group where I will be presenting.

Ubuntu 8.10 and IDEA IntelliJ, no longer slow …

Sunday, March 22nd, 2009

For a while I have had an excruciatingly slow IntelliJ 8.1 under Ubuntu 8.10 with Java 1.6.0_10 and I was considering downgrading until the performance was fixed. Seriously, it was bad with page-down visibly scrolling the screen at about 1 second a line. Not usable at all. Recently I looked again for a fix and the issue is apparently due to Java and is fixed in Java 1.6.0_12, but you can also add the following entry in your /etc/X11/xorg.conf file just under the device section, and it works.

Option “AccelMethod” “XAA”

Secret Agent Person …

Sunday, March 8th, 2009

quality agencies

Finding myself out of work in January was not something I had planned on but since I had a month with pay I thought I would work on a personal project using the Google Web Toolkit and wait until February to find more work. Some of the Agents I came across were extraordinary, and if you are wondering if they were extraordinarily good or extraordinarily bad, then read on.

I saw a job advertised by RMA Online and I applied for it and received a call from them in about 3 hours asking if I would come in and discuss the role. When I got to their office there was a sheet on the reception table outlining their Company “values” and I wondered if they actually stood by the values or if they were just marketing fodder. I was very impressed with Rose who showed each of the RMA values at work by taking the time to find out what I was after and then taking me through the particular role that I had applied for. I never felt like a number or just a potential commission to be shoe-horned into whatever was available. All along the way Rose and Payel kept me informed of the progress of my application and I even got an email to say that my application had been submitted to the client. RMA have excellent service and a set of “values” that I think should be a charter for the industry not just a single company. Kudos to Russell MacDonald for setting up such a great agency. I can’t recommend RMA and Rose highly enough and you can contact RMA through their web site: http://www.rmaitrecruitment.com.au/

A smaller and more boutique agency is Seed Talent run by Rob Simpson and while they are smaller they were just as impressive as RMA and I would recommend them as well. Rob kept me informed every step of the way with the role we were discussing, he was never pushy and always interested in what I wanted and where I wanted to go. Seed is a new agency starting out and I expect they will be bigger and more successful in a short period of time. I recommend Seed and you can contact them through their web site: http://www.seedtalent.com.au/

Seed and RMA treated me with respect and gave me a service that I will remember, unlike one agency who treated me as a number, with the respect you get from caring only about commission and keyword matches. This particular agency said they would put me forward to a client at salary X although we had discussed salary Y and badgered me until I capitulated leaving me feeling sour. After two weeks I wondered what had happened to the role since other agencies were asking if I had been presented and I wondered why I had not been called.  Quite unsurprisingly I received a call to say that the employee I had been dealing with was no longer with the firm which I was glad to hear, and that they would follow up on my application and get back to me. I’m still waiting !!

So the great agencies I dealt with were RMA, Seed Talent and, Interpro.  The agency to stay away from is ??, well I’m not sure I can say.  Haskell, Assembler, Yaml and Smalltalk are interesting topics to some.

Linux, IntelliJ, Ruby and Rails

Sunday, March 1st, 2009

ruby

Recently the people I have been speaking with and working with have been using Ruby and Ruby on Rails and I thought I would try an experimental project to compare Ruby/ROR to working with the Google Web Toolkit. I have been working with IntelliJ as my IDE for some time and I even bought a personal license so I was keen to have Ruby work within that IDE. Maybe one day I’ll get one of those Mac books and use Textmate and really transition to a place where I can call myself a Ruby developer, but for now it is Linux and IntelliJ.

The setup was smooth until I tried to run a few operations in IntelliJ on my newly created project and got an error message about a Gem Manager not being added to the project. Dang, stopped in my tracks and needing to find an answer before I could continue. I scanned the net and eventually found the information I was after and what follows are the steps I took to get my Linux, IntelliJ, Ruby and Ruby On Rails environment running. The steps for Linux and the steps for IntelliJ come from other places and I am just putting them all here in one place to help others and to keep them for the next time I may need them. A special thank you to Ryan, to the Ubuntu Community and to Roman Chernyatchik for all the steps.

Here are the links to the original step, just in case you want more information or a variation on what I have done. Ruby On Rails On Ubuntu  and  Setting Up IntelliJ with no Gem Manager error.

ubuntu-logo

Get Ruby:

sudo apt-get install ruby-full build-essential

I’m using WEBrick so I don’t need to setup any additional servers, but see the Ubuntu link for details.

Get Ruby Gems:

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

Now Install Rails usingRuby Gems (This can take a while):

sudo gem install rails

Install the MySql database and the Ruby connector:

sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

Now update all the Gems:

sudo gem install rubygems-update
sudo update_rubygems

intellij-log

I’m using IntelliJ IDEA version 8.1 and I have not checked if the instructions work with other versions.

Install the Ruby Plugin through the IntelliJ IDEA plugin-manager.

Ctrl-Alt-s and select Plugins
Click 'Available'
Enter Ruby

The list should filter and you should see the Ruby plug-in. Click on it and select install (disk icon) and the Ruby Plug-in should install and you are ready to start a Rails Project.

plugins

Re-start IntelliJ IDEA and choose ‘create a new project’ and select next and there in the ‘Select Type’ list should be an option for a Ruby Module. Click on the Ruby Module and enter the rest of the files for your project and Click ‘Next’.

rubymodule

IntelliJ IDEA will ask you to specify the Ruby SDK. Point IntelliJ IDEA at your Ruby installation, mine is in

/usr/bin

Then click next. IntelliJ will then ask you if you want Rails with the new Ruby project so tick the check box. There is no need to click “more” so click “Finish” and IntelliJ will create the Ruby project with Rails, but we are not done yet.

rubyoptions

Now the Project is created and in future versions of the Ruby plug-in the following steps may not be needed. The plugin version I have is: 2.0.223960.

From the File Menu select the Project structure option (Ctrl-Alt-Shift-S)
Select your Ruby/(Java module with JRuby facet),
Select the “Dependencies” tab,
Click “Add” button at the right side of “Dependencies” tab
Select “4. Global library…”
Select lib with name “[gem] rspec (v.1.x.x, $path)” and “[gem] rspec-rails (…)”.
Click OK button
Click Apply

projectoptions

Now you are good to go and setup your Run configurations to run your rspecs or the Rails application with WEBrick !