Monday, July 7, 2008

Writing, compiling and executing a Qt program on Windows XP

Hi all,

To compile a qt program first make a folder and make a cpp file in this folder and add the appropriate code. For your reference I created a C:\Qt\First and then added a main.cpp with the following contents:
#include
#include

int main(int argc, char* argv[])
{
QApplication app(argc,argv);
QPushButton button;
button.setText("FIRST BUTTON");
button.show();
return app.exec();
}

Then execute the following standard commands one by one:
qmake -projects
qmake
make
This will create 3 make files namely Makefile, Makefile.Debug, Makefile.Release.
To create an executable: type the command: make -f Makefile.Release
This creates a release folder. The executable is in this release folder. Change to this folder and execute the exe.
Remember that every time you change your code, compile your program with the above command to recreate the release which reflects the changes that you have made.
That's it you are on your way to bigger things in Qt

HAPPY PROGRAMMING
For any queries leave your comments and I will get back to you soon.

Cheers!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

MANDELBROT

INSTALLING QT ON WINDOWS XP

Hi all,

This is the trickiest installation I have done. The trick is to have the right information and it is that on a Windows machine only the commercial release is compatible with Microsoft Visual Studio so if you are stuck with strange errors creeping up when you try to install open source edition with msvc option you know where is the problem. Thus, for Qt open source edition install a mingw compiler on your system. The mingw homepage (mingw.org) sucks, the download links have nothing to download, it is the worst website of all open source projects. The work around for this is to download Bloodshed Dev C++. This will install everything that you need to start your installation for Qt. Do remember that if you have microsoft visual studio installed clear the environment variables MSYS, LIB and INCLUDE (NOTE:-To check all the environment variables that are set on your machine, type the following command: set on a windows console.). This is done using "set" command from the console as follows
  1. set LIB=
  2. set INCLUDE=

This clears any entries for visual studio from LIB and INCLUDE. Now comes the steps that you need to take to install qt. I am using Qt-4.3.3 open source edition.
  1. Unzip the Qt folder to C: drive so you have a qt source folder in C:\
  2. I have Bloodshed Dev C++ installed in C:\Dev-Cpp. Add the bin and library sub folder of this folder to your PATH variable using PATH=%PATH%;C:\Dev-Cpp\bin;C:\Dev-Cpp\lib. This would relieve you all the hassles of finding and installing a mingw compiler as Bloodshed Dev C++ automatically installs them for you. Also change your LIB and INCLUDE environment variables (after clearing the visual studio entries) to point to Dev-Cpp and Qt lib and include folder. I made the following changes on the console: set LIB=%LIB%C:\Dev-Cpp\lib;C:\qt-win-opensource-src-4.3.4\lib( I unzipped Qt folder to C:\ drive, if you choose some other path then change it accordingly). set INCLUDE=%INCLUDE%:C:\Dev-Cpp\include;C:\qt-win-opensource-src-4.3.4\include.
  3. Then switch to the qt folder i.e where you have unzipped the qt source folder. In my case it is C:\qt-win-opensource-src-4.3.4. From there type the command: configure -platform win32-g++ to configure Qt for your system. The command will only fail if you haven't set the path for the mingw based compiler correctly other wise in a matter of 5-10 minutes your version of qt will be ready to be built.
  4. When qt is configured run the following command to build qt for your system: mingw32-make. If you face any errors during this step it is most likely that you have visual studio installed and environment variables like LIB, INCLUDE AND MSYS set to point to exe's needed by visual studio. Clearing these variables and setting them as I have explained above will relieve you of your hassles.
  5. Finally add Qt bin directory's path to your PATH variable as PATH=%PATH%;C:\qt-win-opensource-src-4.3.4\bin (in my case).

I hope this does the trick for all of you geeks who were hitting a dead end while installing Qt on your windows machines. For any further queries you can send a comment and I will try to answer them to the best of my abilities.

Cheers!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thursday, March 27, 2008

Travel Advisory To India

HI ALL,

Well for all the foreign nationals visiting India there are few points that you must strictly adhere to if you do not want to turn your Indian picnic into a nightmare. Women travelers should be extra cautious while visiting India. Crime against women is a norm in India.
  1. Never ever fall into a trap if some one tries desperately to befriend you.
  2. Stay clear of secluded spots.
  3. Do not travel or party late nights. Call of a night at max 11:00 pm. It is always better to be safe than sorry.
  4. Most guides and travel agents will try to rip off so cross check with your fellow Indian travelers with the correct fares and prices of commodities.
  5. Be extra cautious about your baggage and guard against even children, as in the garb of their innocent looks they will make do with your booty.
  6. Stay away from cheap accommodation. In the past 3-4 years there have been many instances of rape by the staffers of these cheap hotels (or motels as they are called in the US).
  7. For female travelers, it is better if they have a male company otherwise it is very dangerous to tour India. Also for the female travelers, despite the hot weather it is always advisable to wear clothes that cover most of your body as it eliminate any unwarranted attention from some (in fact most) Indian men with hight testosterone drives.
  8. Drink only bottled water. Some good one are BISLERI, AQUAFINA, KINGFISHER etc. Insist on these two as other ones are cheap duplicates that compromise both on your money and health.
  9. Do not try the street food because only Indian people have the digestive system to filter this stuff.
  10. Lastly if you are traveling with your teen aged children (especially girls), make a point that they are with you all the time. The case in point is the molestation of British girls by some Keralite hooligans on the new years night 2008 and the more recent Scarlette Keeling murder case.
Being an Indian citizen it is my responsibility that whoever visits my country has a pleasant and happy time. It absolutely disgust me to see violent crimes being committed against tourist especially women. The above 10 points are to be kept in mind by any traveler visiting India and believe me it will nullify at least 70 percent chance of the tourist getting into trouble. I think Women travelers should strictly follow the above 10 points to ward off any unnecessary hiccups in their visit to India. The rest is up to the destiny of the individual travelers.
Lastly and most importantly, follow your intuition and gut feeling because even the airports are not safe in India. This is proven by the fact that cases of molestation are common place at the IGI airport New Delhi.

Happy touring India

Wednesday, March 26, 2008

Most Indian Men Are Lechers

Hi all, being an Indian male gives you a free hand in giving the females a tough time. Having observed the psyche of Indian men especially over a period of time I find them chauvinist, lecherous towards the fairer sex. In market places I quite often see men and boys ogling at women (don't ask me places where they focus there eyes on). At crowded places they never miss any opportunity to get there hands on a women's assets, testimony to it are the famous incidents of eve teasing in Mumbai during the last 2 new year revelries. Today as well while buying fruits I could see a group of boys ogling and passing obscene comments on two foreigner girls. Seriously there has to be done something about it. It is happening all too often and the audacity of these people is scaling new proportions day by day.
I find these men and boys very weak from inside that is the reason they want to show there manly side by resorting to such petty things. It would rather do there future some good if they could spend this time on some constructive endeavors. I always believe that harassing a female or abusing her body is the worst sin that anyone could commit but the same is being committed with such impunity that it has become a norm rather than an exception. If a stand is not taken against these crimes then GOD save Indian women.
All the talk about our culture is sheer nonsense and bullshit. In the garb of our cultural heritage all the wrong that could be committed against women is committed. How many of us realize and accept rape within marriage? These are just some of the issues about which I am really concerned and would soon file a public interest litigation to do my bit. Till then if any of you feel the same as me, your comments are always welcome.

Saturday, January 5, 2008

Installing Qt on linux

Download Qt's latest version from www.trolltech.com, I downloaded the source in tar.gz form and compiled it on my machine. It took 1+ hours (Intel 2.4 Ghz. 256Mb RAM running RedHat). It'll jetset on latest machines.
  1. Switch to the directory containing the source and type the following command: tar -zxvf .tar.gz
  2. It will create a directory with extracted contents and tar.gz removed. Change to this directory.
  3. Type the following command: ./configure This checks for the dependencies(i.e other softwares if any, required to install qt).
  4. Then type: gmake. This compiles your qt source code.
  5. Then type: gmake install. This installs qt on your machine.
  6. Note that if you have qt installed on your machine already then to use its latest version you have to set the path of your qt bin file, which you can do by typing the following commands:
PATH=/bin:$PATH
export PATH 

For example on my machine after step 5 qt version 4.3.2 was installed in
/usr/local/Trolltech/Qt. Thus I used the following command:
PATH = /usr/local/Trolltech/Qt/bin:$PATH
export PATH
You can also set the PATH variable in your .bash_profile file, but the above method saves you the hassles of editing the file. So take your pick and get on the Qt bandwagon. For any queries regarding installation on the linux box especially redhat contact me on this blog.

Sunday, December 30, 2007

Some Facts about Linux Source Code

Hi all, I have been fascinated by the Linux/Unix OS from the time I started to use them. The Linux OS gives another meaning to freedom and this is where it truly scores over big brother Microsoft. The source code is free, any user can play with it and use his/her creative faculties to get added functionalities.
The Linux kernel is made up of 6 million lines of C code and takes up 230MB of disk space. Written in a book form it would atleast take up 50,000 pages. The code is not commented and thus trying to understand it, is the challenge and beauty of working on the Linux kernel. The major part of the kernel are the ones implementing memory management.
These are very few snippets that I found when consulting various books. I would be updating the information about the linux kernel and Linux Os in general. Till then Keep blogging.