Getting started for Qt and C++ development on windows

by iampeterbanjo on February 28, 2010

I came across a programming framework called Qt that has recently been acquired by Nokia. It’s primarily for C++ based development and allows you to write code which can be compiled for Windows, Linux AND mobile. It’s the mobile part that really got me interested. Check out these videos if you’re curious.

Unfortunately, as with most frameworks, the binary installer doesn’t do EVERYTHING you need to get started. So noob-to-noob this is how I got myself started on Qt on Windows.

Install binaries

Get the Qt SDK and Qt Libraries 4.6.2 and install.

Set paths

Go to: Start menu > Computer (Right click) > Properties > Advanced properties > Environment variables

Add these to PATH (Path > Edit)
C:\Qt\2010.02\mingw\bin;
C:\Qt\4.6.2\bin;
C:\Qt\2010.02\mingw\mingw32\bin;
C:\Qt\4.6.2\qmake\generators\win32;

Add new for user
QMAKESPEC win32-g++
QTDIR C:\Qt\4.6.2

Edit classpath
C:\Qt\2010.02\mingw\bin;
C:\Qt\4.6.2\bin;

Log out and login or restart for changes to take effect

Build Qt Libraries

Go to: C:\Qt\4.6.2\bin

Open qtvars.bat
Save as qtvars.bak.txt
Edit qtvars.bat
Delete all lines that modify the PATH i.e. lines 6 – 17.

Open command window in C:\Qt\4.6.2\bin
Run: qtvars.bat compile_debug

Go to: Start > Programs > Qt by Nokia 4.6.2 > Qt 4.6.2 (Build debug libraries)

Sip coffee while you wait. . . wait . . . wait.

UPDATE

You don’t need to build the libraries to get the IDE to work.

If you get this error when you run a build (probably going through a tutorial like I did) -

C: \ Qt \ 2010.02.1 \ qt \ lib / libqtmaind.a (qtmain_win.o): In function `WinMain @ 16 ‘:
C: \ qt-greenhouse \ Trolltech \ Code_less_create_more \ Trolltech \ Code_less_create_more \ Troll \ 4.6 \ qt \ src \ winmain / qtmain_win.cpp: 131: undefined reference to `qMain (int, char **)

It’s because your function doesn’t have a main method. So try this –

   1:  int main(int argc, char **argv){
   2:    //code goes here
   3:  }
  • Share/Bookmark

JavaScript debugging – keeping track of your variables

by iampeterbanjo on February 28, 2010

One problem that I keep running into writing JavaScript is trying to keep track of all the objects and variables. With other programming languages your IDE of choice helps you step in and out of functions, insert breakpoints and show you how your variables are being modified. What do you do if you are writing JavaScript which doesn’t have this level of support and you don’t want your console logs printing out on a live site?

I use -

   1:  if(window.console && debug){
   2:      console.log('my variables ');
   3:  }
   4:   
   5:  var debug = true;

What this statement does is check for an instance of a console. The console is a web development aid included most modern browsers, excluding Internet Explorer.  If it present, “window.console” is true which avoids IE throwing errors when it gets to “console.log”.

The next variable is “debug”. I set this to false once the code is ready.

The benefit is I can log the progress of my program(s) in JavaScript as I develop. If the code is sent back for modifications/improvements/troubleshooting I can turn on the logging and more quickly find out where the problem is. Most useful before 10:30 am and at around 3 pm. ;-)

  • Share/Bookmark

Web Development as a science

by iampeterbanjo on November 8, 2009

I was talking with some co-workers this week and I commented that I think we are getting to that point in the web development industry where things need to start coming together as a science. And by science I mean a discipline that is able to give you a predictable outcome. At the moment web development borrows a lot of skills, from graphic design to programming, without forming a consistent body of knowledge. I like this quote form Kelly Norton on the Google web tool kit blog -

I’ve sometimes thought that optimizing web applications is as much a science as dowsing. (No offense intended, dowsers of the world — but you have to admit it’s a hard thing to explain even when it does work out.) Even when you are completely willing to invest time and energy into optimizing an application, how do you actually go about it?

I think dowsing is an apt metaphor but what woud this body of knowledge look like?

1. Design: A pattern for designing achievable websites.

You can get a some Photoshop templates including some nice grid based designs. But seriously, don’t talk about pixel perfect development if you don’t have pixel perfect designs.

Developer: Oh, I like that transparency (but really thinking, epic fail in IE6). Are we supporting IE6?

Designer: Yes.

Developer: (To project manager) How long is this supposed to take?

And don’t even start about using JavaScript to fix PNGs in IE6. Been there, done that and it can still be a huge time sink depending on the design. You know what happens when a developer comes across a huge time sink and an impending deadline? Bugs. Sorry, guys the secret was already out in Peopleware.

2. Develop: Guidelines for solving problems effeciently – this includes CSS, HTML and JavaScript.

I think the best way forward for HTML is the Semantic web including Microformats because you can write the same mark-up and use it in many different ways. The Mozilla Development Community has this nice article about writing effecient CSS and there is a movement towards Object Oriented CSS which I like – probably because of my formal programming background. The less redundancy I have in my life the better. The rule of thumb for JavaScript seems to be “Find a framework and stick with it”. jQuery is what I use most.

3. Test: A testing framework

This is where it gets interesting because I think there is a big need for this. There’s NUnit and JUnit and all kinds of gangsta sounding testing frameworks for other languages but on the net all we have is JS Lint. No offense to JS Lint but can we have some regression testing with ketchup please? But what would you expect when we are still terrorised by the Internet Explorer Trident Engine which is built on the mysteries of the Universe? Testing is important to ensure code quality and shorten lead times.

And then you say, “But Peter, you can use JUnit with the Google web toolkit”.

Segregation vs. Integration

I couldn’t really think of a better title so this will do for now. What I am trying to get at is two approaches to getting consistent results in a web development process – less time troubleshooting and more time having fun. On one hand I can see Yahoo!’s YUI and on the other Google’s Web Toolkit and now Closure Library. Yahoo! and Adobe seem to be on the same page on this where it feels like a design led approach.

Segregation

Bring me all your layouts, CSS and semantic HTML – plug it into my library and let me upgrade you.

Which is great for existing web development teams that are broken along functional lines of designers and developers. So the product of each process remains segregated: they can live independently of each other. Your HTML can have a different life-cycle to your CSS or JavaScript. This is nice because many people with different skill sets can work on the same problem. Also nice if you already have site that you want to spice-up a bit.

Integration

Google seems to be saying,

Come to me all who are object oriented and are strongly typed and I will give you HTML.

If you’ve already worked out your sweet science in Java, Python et al. why re-invent the wheel? Just port it into whatever format you need – integration. Great for code monkeys . . maybe you can fit a designer or two into the workflow but I think there is less variety in this process.

Hammers and nails

The problem with only having a hammer in your toolbox is that every problem looks like a nail. I can see how for enterprise applications Google’s philosophy is a god-send. You might already have a Java code base and all you need is a new interface or two. Write a few facade classes and you are on your way to a new intranet site or whatever.

But I am biased to the idea that the web offers such a rich range of experiences and possibilities. Do you remember how boring the internet was without Flash? All that reading, reading, reading. Having a diverse group of people working on a platform, in cross-disciplinary manner, will create rich set of possibilities.

Ideally I would like to believe that the integrated development environment will generate the best code possible but what if I want to make changes to the generated code? Maybe put in some microformats? Some hacks for IE9 perhaps? It’s the same problem that Model Driven Architecture has.

To be fair, this is an abstract thought experiment and time and experience will have their say. . and so can you.

  • Share/Bookmark

Book review: Outliers by Malcom Gladwell

by iampeterbanjo on October 25, 2009

Oops, I did it again. This is not a book review in the purest sense of the written word. It is more of an audiobook review to be more exact.

I had to read, I mean listen, to this book. My brother was raving about it, it was being mentioned everywhere, I saw a presentation by Malcom Gladwell at an AIGA conference . .  I had no choice.

The big idea in this book is that really successful people, like really successful, are not products of chance but of systems that are selectively biased to favour certain individuals over others. The best example, given at the start, is that of hockey and football (soccer, hello Americans :-) ) players. By setting eligibility dates for admission the scales are tipped to favour those who are the most mature by those cut-off dates.

Another noteworthy example is Bill Gates who was fortunate enough to go to a high school that happened to have mothers who raised money to invest in the science department, who happened to have a pupil whose father donated advanced computing equipment, and also happened to go to a college with some more computing facilities . . etc. etc. etc. And now we have one of the richest men in the world.

Now instead of crying over all the opportunities I didn’t know I didn’t have till I read this book, I want to try something out. A point Gladwell makes is that if we identify areas in which we are disadvantaged we are able to systematically overcome them. If it takes 10,000 hours to become an expert at something, then I better start counting those 10,000 hours, shouldn’t you?

 

  • Share/Bookmark

Book review: Made in Japan by Akio Morita

by iampeterbanjo on October 25, 2009

You know, after reading this book I fell in love with Sony. It’s so hard to resist the human element of Sony’s history. From the humble beginnings in a devastated city after the second world war and the ambition Morita showed to pursue his dreams with a trusted mentor and friend, Professor Ibuka. It is a classic rags to riches story, what is there not to love?

But just as important were the ideas with which they shaped this new company. How do you build an innovation machine? Allow researchers to pursue personal interests that may not have short term goals but may be of long term strategic importance.

Giving colour and insight to this story are Morita’s reflections on Japanese history, work culture and the future. If you want to understand a little bit of where “life-time employment” came from then read this book.

The book meanders in some places and has personal opinions mixed in with factual information but it is was an easy read.

I will leave you with this quote of Morita speaking about his colleague Professor Ibuka -

"Ibuka is a great person with great leadership qualities – he attracts people to him and they invariably want to work with him. In fact, the history of our company is the story of a group of people trying to help Ibuka make his dreams come true. He never believed in one-man management. It was not only Ibuka’s genius and originality in technology fields or his ability to look in the future and accurately forecast for us accurately that struck everyone so forcefully, but his ability to take this group of young and cocky engineers and mold them into a management team that could cooperate in an atmosphere where everybody was encouraged to speak out."

I might have overstated things when I said it was a rag to riches story. Morita’s family had a successful family business and he had been groomed, as the first son, to take over. Which brings us to …

  • Share/Bookmark

Book review: Samsung vs. Sony

by iampeterbanjo on October 25, 2009

The book begins with an open question, in 2002 the market capitalization of Samsung surpassed that of Sony, how did this happen?

The author thoroughly explores the differences between these two companies – one a well respected icon in electronics and the other a young upstart with a coloured past. And comes to rest on the conclusion that it is the companies deep seated structures, processes and environments which have allowed Samsung to not only catch up but to overtake Sony.

In a summary that will not do justice to the book, Samsung has a strong command and control structure that has allowed them to make strong profits from building parts for other companies, mainly memory chips, at the best price. They invested aggressively in their business and by some clever strategic thinking positioned themselves to become a quality brand to escape the harsh realities of always trying to be the cheapest bidder.

Sony because of their charismatic founders Akio Morita and Masaru Ibuka embraced an open culture that allowed creativity to flourish. They focused their attention on premium products and creating markets. That worked well in the beginning but managing a global enterprise has been a challenge for their successors.

It is like reading a book of modern warfare but nobody has to die. In fact, for a while neither of these companies were in direct competition with each other.

What is in it for you? Are you in an industry where you are trying to make more for less or you want to create something so cool everybody will pay you just to look at it? I find myself leaning towards the latter and this is a history lesson that will be good to learn from – if you don’t want to be overtaken like Sony has been. But the story isn’t over because Samsung is struggling with innovation and Sony have the oppotunity to learn from their mistakes

At the same time I was reading this book I was also reading…

 

  • Share/Bookmark

Book review: Blown to Bits by by Philip Evans and Thomas S Wurster

by iampeterbanjo on October 25, 2009

My goodness I loved this book! I got this book from the library because it had such an intriguing opening and was so densely written: the authors didn’t waste time getting to the main points and they had a whole lot!

The main argument of the book is this – there are two general economic principles, the economy of things and the economy of information. They are unique and are governed by different rules. Take a letter for example. The value of that letter is made up of the physical artifact that it is printed on and the information it contains. What would happen to its value if you were to separate the two? Would the letter become worthless? Think of maybe a love letter or a degree . . a prescription perhaps . . . hmm.

That is what is happening all around us. Computers have enabled us to separate the economy of information from their physical objects and the crazy thing about the economy of information is that the cost of creating new information is approaching zero – it scales logarithmically. You print your first book with the first printing press – how much does it cost to print the next one? I write a blog. How much does it cost to reproduce my blog somewhere else? Nothing.

With all this information – as your mailbox will testify after a you go on holiday – it creates an opportunity for someone to provide a service to navigate this ocean of data and make it meaningful – search engines. And by becoming gate keepers and aggregators they recreate value in new and creative ways. Pay-per-click? Google ad-sense? Who saw that coming?

Would Wal-Mart be Wal-Mart without the intense cost cutting that is made possible by the advanced information systems that they use to manage their suppliers? At the heart of the Toyota Production System is the ‘anban’ signaling protocol used along the production line which in essence is an information management tool.

It is intimidating to feel like just another 1 or 0 in the bit stream but the authors leave us with this reassurance –

What resists deconstruction is the idea of the corporation as defined by its culture and its strategy. The corporation as purposeful community. And if all else fades, perhaps purposeful community becomes the essence of identity, of management, of leadership. In a world of impersonal technical change, that is a refreshingly human thought

Speaking of new and interesting ways to use knowledge, did you know that the transistor invented by Bell Labs, which they did not know what to do with, brought fame and fortune to Sony? Which relates to a point that Drucker made that it is becoming more and more important for management to know what is happening outside of their industry because this is where transformative change is going to come from.

Did someone say Sony? Segue please…

 

  • Share/Bookmark

Book review: The Toyota Way by Jeffrey Liker

by iampeterbanjo on October 25, 2009

Full disclosure – I didn’t read this book, I listened to it via an audiobook that I bought on iTunes. Actually I haven’t listened to ALL of it because it can get really dry in some places (after about an hour) but can I please write a review anyway? Thanks.

So, car manufacturing. How do you unseat GM as the number one car manufacturer? Reinvent the wheel? No, you simply continuously improve the wheel until it basically propels itself uphill. The process of continuous improvement is called ‘kaizen’ in Japanese.

The target vocabulary for today is

  • Kaizen – continuous improvement (for those who were not paying attention)
  • Muri – waste
  • Anban – signaling system

What Toyota have been able to do is create a production system that repeatedly outperforms any other through a process of eliminating waste (muri), investing in their employees and an eternal learning cycle – and a few other things. What does ‘anban’ have to do with this? Buy the book.

I picked up this title because I wanted to learn a thing or two about how I can improve the work that I do. No, I don’t make cars but we are all working with the same capital, Toyota and I, knowledge.

Almost every other day as my computer sloooowly does what I try and tell it to do I wonder if there could be a better way to do what I am trying to do. That is the same question Toyota asks themselves, apparently. Web standards are evolving and who knows how long a piece of software takes to come out of beta – if ever. This means I have to stay current, and hopefully ahead, by developing a learning habit. Toyota has taken this to near perfection. For example, when a mistake is made on the production liner there are huge televisions that display the mistake to everyone so it is not repeated – without punishing whoever made the mistake; that will soon defeat the purpose.

In fact when I was reading “Managing in the Nex Society” Drucker remarked that Toyota is rumoured to be thinking of offering their expertise in effeciency as a service. Knowledge is like the wind, it has no boundaries. This is a good jump-off point to . . .

  • Share/Bookmark

Book review: Managing in the Next Society by Peter Drucker

by iampeterbanjo on October 25, 2009

What effect will the ageing population have on the nature of the corporation? In what ways can management source, cultivate and retain knowledge workers? Who are knowledge workers anyway?

In a collection of short essays Peter Drucker tries to answer these and many other questions, in what I found to be a very interesting book. What I find most unique is  the historical reference in which he is able to make his arguments. There is an assumption that the digital revolution is unprecedented and in many ways it is, but Ducker makes a convincing argument that it has a precedent in the revolution brought about by the railroads in 1829.

Also enlightening are his views on what it is going to take for corporate, government and community based organizations to create urban societies that allow people to develop a sense of fulfillment given the dislocated and highly mobile nature of a new work culture.

What is worth noting is that economies are changing from manufacturing driven to knowledge based economies. And this is very clear if we take a look at the quintessential manufacturing process – car manufacturing.

 

  • Share/Bookmark

Quick tip: searching for unread mail in Gmail

by iampeterbanjo on October 17, 2009

We all love our inbox but what do you do when there is just too much mail to go through and you want to just “Mark as read” all of them? In Gmail you a can find all that unread mail in just two steps.

1. Click on search options

Gmail-unread-mail

2. Select unread mail in the drop down menu

Gmail-unread-mail-search-op

Now you can see all your unread mail and do with them as you like.

  • Share/Bookmark