Sunday, April 24, 2011

How to install Qt for Visual C++ Express Edition

Qt is a cross-platform GUI toolkit, whose SDK available under LGPL licence so that we can use it for free. It uses MingGW (gcc) compiler, which is not good as Visual C++ compiler. So you would like to use it together with, let's say Visual C++ Express edition. However, installing it with Visual C++ Express edition is little bit tricky. We have to build it with Visual C++ and here is how it is done.

Step 1
Download and install the LGPL Qt SDK for Windows. You can ommit installing MingGW; it is assumed that you have already installed Visual C++ Express Edition.

Step 2
Open Visual C++ Express Edition's command prompt. (Tools->Visual Studion Command Prompt)

Step 3
Change the directory to Qt installation direction (usually it is something like E:\Qt\2010.05\qt)

Step 4
run configure
(use options with it so that it will be onfigured to use with the msvc2010 platform
for e.g. configure -no-sql-sqlite -no-qt3support -no-opengl -platform win32-msvc2010
   -no-libtiff -no-dbus -no-phonon -no-phonon-backend -no-webkit)

Step 5
Build Qt by typing nmake
Here is where you will encounter all sorts of trouble. It can stop abrubptly giving you an error message. Type nmake again and try to build it once more. It can get resolved automatically but if you are stuck with the same error like,

c:\Qt\2010.05\qt\src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\moc_SocketStreamHandlePrivate.cpp(97) : error C2065: 'QSslError' : undeclared identifier2.c:\Qt\2010.05\qt\src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\moc_SocketStreamHandlePrivate.cpp(97) : error C3861: 'socketSslErrors': identifier not found3.Generating Code...4.NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'5.Stop.6.NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'7.Stop.8.NMAKE : fatal error U1077: 'cd' : return code '0x2'9.Stop. or

then, you have to go and check for these files and delete them.
  1. delete files \src\script\tmp\moc\debug_shared\mocinclude.tmp and \src\script\tmp\moc\release_shared\mocinclude.tmp and restart nmake
  2. delete files \src\3rdparty\webkit\WebCore\tmp\moc\release_share d\mocinclude.tmp and \src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\ mocinclude.tmp and restart nmake.
Remember that nmake will take time. Just be patient.

Step 6
Finally it is time to let the Visual C++ Express Edition know where the include, library and executable files of Qt are located at.

This can be easily done using a project property sheet.

  • First go to View in VC++ Express Edition and check whether the Property Manger is there. If not, go to Tools->Settings and choose Expert Settings.
  • Next, choose Property Manager from View; this will open up Property Manager side-by-side with solution explorer and Class view.
  • Right click on top of your project name and since this is first time, click "Add New Project Property Sheet" and give a suitable name for your property sheet.
  • By double clicking on the file name open the newly created property file.
  • Under common properties->C/C++->Additional Include Directories, insert
    • "..\..\..\include\QtCore";"..\..\..\include\QtGui";"..\..\..\include";"..\..\..\include\ActiveQt";
  • Under common properties->Linker->Additional Library Directories, insert
    • <your Qt directory>\2010.05\qt\lib;<your Qt directory>\2010.05\qt\lib;
  • Under common properties->Linker->Input->Additional Dependencies
    • <your Qt directory>\2010.05\qt\lib\qtmaind.lib;<your Qt directory>\2010.05\qt\lib\QtGuid4.lib;<your Qt directory>\2010.05\qt\lib\QtCored4.lib;
You can use this same property sheet when you create other Qt-based projects.

Wednesday, April 20, 2011

Figures in LaTex documents

I ran into some problems inserting figures in a LaTex document in TexnicCenter using the LaTex=>PDF configuration. When you create direct pdfs you will be using pdflatex binary, which does only deal with jpg, png image files. In the process you will loose image quality and sometimes encounter other problems; well, I had such a problem where I could not properly span my figure to column width in a two column document.

When you insert figures in your LaTex document it is better to create .ps files (LaTex=>PS) as the quality of your images will be preserved. In this configuration, you have to use image files in .eps format. Use GIMP software to convert your image files into .eps format. Also, it is better if you drag the file into GIMP so that you do not have to worry about the size of your image. And then save it in the .eps format.

So, once you create the .ps file use GSView software to convert it to .pdf files. In the process of installing GSView you will be required to install Ghostscript software as well.

A very simple code for inserting a figure in LaTex would look like this.

\section{Methodology}
The schematic diagram of the proposed system is given in Fig.~\ref{fig:robot}
\begin{figure}[htb]
 \begin{center}
  \includegraphics[width=\columnwidth]{images/robot.eps}
  \caption{Some figure}
  \label{fig:robot}
 \end{center}
\end{figure}


Do not forget to include
\usepackage{graphicx}
at the top 

Tuesday, April 19, 2011

View Output with Adobe Reader X in TeXnicCenter

I could not enable this facility in TeXnicCenter for new Adobe Reader X and it did not work out with default settings. After googling for this issue I found a solution from here.
And, I am sharing it with you guys.

  1. Enter TeXnicCenter output profiles screen by pressing ALT+F7.
  2. Select LaTeX => PDF
  3. Open the Viewer Tab
  4. Make sure that the new Adobe Reader executable path is pointing to the newly installed version, rather than an obsolete path. Common paths are:
    1. C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe or C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe
  5. Next, select DDE command in each section (3 times). Enter “acroviewR10” in each Server text box (3 times), and “control” in each Topic text box. In the first two Command text boxes (View project’s output and Forward Search sections) fill in:
    [DocOpen("%bm.pdf")][FileOpen("%bm.pdf")]
    And in the last Command text box (Close document before… section) fill in:
    [DocClose("%bm.pdf")]

Credit goes to original contributor.

Tuesday, April 12, 2011

Copying files in command prompt in windows

Copying files in windows is quite easy; just right click on the folder you want to copy, then select copy and then paste wherever you want it to be. However, you may have experienced that if copying stops due to some error, even the amount copyied upto that point can disappear. In that case you may want to use the command prompt for copying.
xcopy is a powerful version of the copy command with additional features; has the capability of moving files, directories, and even whole drives from one location to another.

To copy from folder1 to folder2, the syntax would be
xcopy "C:\folder1\*" "C:\folder2" /k /e /d
where
/k - Copies attributes. Normal xcopy will reset read-only attributes.
/e - Copies directories and sub directories, including empty ones.
/d[:mm-dd-yyyy] : Copies source files changed on or after the specified date only. If you do not include a mm-dd-yyyy value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.

For additional parameter information you can have a look at here.