Friday, March 28, 2008
Monday, March 17, 2008
...as amateurish as a filename with a space in it breaking their tools (qmake) it makes you wonder.
Specifically, if you have a file name 'My Filename.cpp" and you run "qmake -project" you get a project file that has failed to wrap the filename in quotes which is required by "qmake -makefile" - ridiculous. You have to edit the *.pro file by hand.
You're probably thinking what I was thinking "there's a switch or option somewhere that he's missing" - nope.
So - If you find your attempt to produce a makefile resulting in weird errors where one filename becomes two, edit your *.pro and wrap those filenames with spaces in quotes yourself ;).
I found myself with some free time the other day and wanted to play with using Qt on Windows as I have been using it for fun on various Linux flavors for years. I even went so far, on Linux, as to write an 'intellisense' like autocompletion class that I put into my own little code editor (because I deal with a lot of APIs both in my day job and my own activities.)
This time though I wanted to use it with Visual Studio 2005 and let VS do the work for me. Some initial attempts at this (I am using the open source windows version which is available as of Qt4.x) failed miserably but I finally managed to get things going after checking a few blogs (most notably Bennet Smith's.)
The version of Qt I am using is Qt 4.3.4 (you should know this because qmake command line args change occasinally [as they have between 4.x versions already]) so this should work for you if you have installed and built Qt 4.3.4 on your Windows box and have Visual Studio installed correctly.
The general process, at least for me, is to create a new toolbar in VS and add two buttons to it for triggering "qmake -project" and "qmake -makefile", then to create a Visual C++ Makefile project and edit the nmake parameters of the project. After this you should be able to use both intellisense, debug, and build using your normal build methods without a hitch.
Let's get started!
Step 1 - create a new toolbar to contain your new Qt specific commands
We want to create 2 buttons, both run the 'qmake' command, the first one runs qmake to produce a *.pro (qmake project) file and the second one generates a makefile from that *.pro file.
(1)In VS select ToolsExternal Tools to bring up the external tools menu.
(2)Press the Add button, and fill in the following properties as below:
Title: qmake project
Initial Dir: $(ProjectDir)
(3)Press the Add button and fill in the following properties as below:
Title: qmake makefile
Arguments: -makefile -spec win32-msvc2005
Initial Dir: $(ProjectDir)
If you wish, you can also set the checkbox for "Use Output Window" for these buttons (I do in case there's a problem) You may also wish to add buttons to launch Qt Designer and Qt Assistant here as well (as I did.)
Now that you have new external tools configured, let's put them on a new toolbar to help us build Qt projects.
To add a new toolbar to VS go to ToolsCustomize and then select the Toolbars tab on the dialog and press the New button. Put in whatever you want for the toolbar name, because you may ultimately have more than one version of Qt installed I recommend putting something like "Qt 4.3.3" as the title.
To add the buttons we want to this new toolbar choose the Commands tab on the Customize dialog, then find the Tools entry in the categories listed and in that sub-category find the external commands.
You need to figure out which commands are your qmake commands because for some odd reason VS simply gives them numbers. For most people they will be the two last external tool entries by number but for others who have had other external tools installed and then uninstalled (such as myself) you may have to count the number of entries for external tools in the drop down menu on the main UI because in my case my qmake entries were #10 and #11 and I had external tool numbers all the way up to 23.
You can simply drag the entries from the sub category list onto the toolbar and the title should show up and tell you if you've selected the correct entry. If you just see 'external tool #
Step 2 - Create a VS project file for use with Qt
(2)Under Project Types, choose General
(3)Choose Makefile Project from the list of sub projects now showing
(4)Give it the location you desire
(5)Press the Ok button and when the application wizard pops up press the Finish button
Now that the project has been created, we need to edit some of its properties:
(1)Bring up the project's properties
(2)Choose Debug as the project type
(3)Choose Configuration Properties
(4)Choose NMake, and under the NMake properties on the right side:
(5)Set Build Command Line to: nmake debug-all
(6)Set Rebuild All Command Line to: nmake debug-clean debug-all
(7)Set Clean Command Line to: nmake debug-clean
(8)Set CLR Support to: No CLR support
(9)Add to Preprocessor Definitions: UNICODE; QT_LARGEFILE_SUPPORT; QT_DLL; QT_GUI_LIB; QT_CORE_LIB; QT_THREAD_SUPPORT
(10)Set Include Search Path to the corresponding locations of your Qt install:
(mine for example are: C:\Qt\4.3.4\include\Qt;C:\Qt\4.3.4\include\Qt3Support;C:\Qt\4.3.4\include\QtAssistant;C:\Qt\4.3.4\include\QtCore;C:\Qt\4.3.4\include\QtDBus;C:\Qt\4.3.4\include\QtDesigner;C:\Qt\4.3.4\include\QtGui;C:\Qt\4.3.4\include\QtNetwork;C:\Qt\4.3.4\include\QtOpenGL;C:\Qt\4.3.4\include\QtScript;C:\Qt\4.3.4\include\QtSql;C:\Qt\4.3.4\include\QtSvg;C:\Qt\4.3.4\include\QtTest;C:\Qt\4.3.4\include\QtUiTools;C:\Qt\4.3.4\include\QtXml)
(11)Set the project type to release and perform steps 5-10 replacing the word debug with release
Now, save everything, and before you do anything else, press the qmake project button on your toolbar (this should generate a *.pro file in the solution directory) and then press the qmake makefile button (this should result in a Makefile being placed in the project directory) and now you can simply choose "Build Solution" from the Build menu of VS and everything should be up and running.
Hope this helps someone out there :)
Wednesday, March 12, 2008
...try configuring X to avoid using the default detected S3 driver like below (other Linux distributions use other methods but below should work for OpenSuse flavors):
(1)Boot using "3" (without quotes) as an option to initiate a command shell
(2)Enter the command: "sax2 -m 0=vesa" (without quotes)
(3)Wait for the confirmation window and choose "Ok"
(4)Reboot and start as you would normally
...there's a 'quirk' with Virtual PC that can make it difficult for the installer (in my case OpenSuse 10.3) to detect your mouse/keyboard properly, to get around this try adding the installer boot option "i8042.noloop" (minus the quotes of course.)
Also, if you're mounting the install from an ISO, this can be problematic as well. If the install keeps asking you to put in CD1 (or any type of media it shouldn't be asking for), try burning the ISO to disk and asking Virtual PC to let the virtual machine grab the CD/DVD drive as this fixed some problems I was having as well.
I hear that you need to change the framebuffer's color depth to 16-bit (from the default of 24-bit) after install as well, but we'll see about that later...