PDA

View Full Version : Small task for Windows programmers



wysota
25th October 2007, 10:10
I have a small and probably very simple task for people programming for Windows. Correct me if I'm wrong, but if you compile Qt from sources on Windows, you don't get start menu entries related to the build. Of course one can always create such a group and shortcuts himself, but why not write a small batch script that would do it for us? We could place it in the wiki, so that people can benefit from it. From my point of view the script should create entries such as shortcuts to Qt tools - Designer, Assistant, Linguist and to a Qt command prompt with all variables set - just like the menu Trolltech creates when installing from binary. Or maybe such a script already exists? In that case, could you point me to it?

Brandybuck
25th October 2007, 19:02
...but why not write a small batch script that would do it for us?
Are you volunteering?

wysota
25th October 2007, 22:26
No, I'm looking for a volunteer :) I'm not experienced in Windows. I don't know how to add an entry to the menu from within a script, etc.

Are you volunteering?

Do you think this is a sane idea at all? It's just something that came to my mind after compiling Qt on Windows...

marcel
26th October 2007, 08:07
. I don't know how to add an entry to the menu from within a script, etc.

You can go around that and copy the links to the start menu folder. :)

But I'll see what I can do when I have the time, maybe in the weekend. That is if someone doesn't do it till then.

wysota
26th October 2007, 09:16
But I don't have the links. I don't have a binary release installed, just the source. So the steps needed are:
1. create links
2. create a folder in the start menu
3. move links to the above mentioned folder
4. create a script that will setup all the vars
5. create a link that will run the script
6. move the link (or the script directly) to the folder
7. say "voilla" :)

Brandybuck
26th October 2007, 19:33
Are you volunteering?
No! I don't know much about Windows either. Which is why I use NSIS or BitRock to install Qt apps on that godforsaken platform.

marcel
26th October 2007, 20:21
No! I don't know much about Windows either. Which is why I use NSIS or BitRock to install Qt apps on that godforsaken platform.

I first want to say that I literally hate Windows and any other MS product! But "godforsaken"? Come on guys... That operating system is more popular among developers than all the other platforms.
I don't know much about the IT industries int you countries, but how does a developer can earn a decent buck there? From Linux programming? A .NET or JEE developer makes far more money than a developer doing c/c++ in Linux . I think that's a fact, at least for the past few years and at least a few to come.

wysota
26th October 2007, 23:46
For me it's easier to find a well paid assignment abroad than to look for it in Poland. I would probably find something I'd like to work on, but I doubt I'd be satisfied with the financial side of it. That's why it says "freelancer" in my LinkedIn profile.

marcel
27th October 2007, 20:11
But I don't have the links. I don't have a binary release installed, just the source. So the steps needed are:
1. create links
2. create a folder in the start menu
3. move links to the above mentioned folder
4. create a script that will setup all the vars
5. create a link that will run the script
6. move the link (or the script directly) to the folder
7. say "voilla" :)

Voilla!
Since what you asked for is not possible with a batch script, I turned my head towards WSH. So you guys can find enclosed a small vb script, which you can test. If your Windows installation is somehow missing wscript, then you're out of luck, but normally, it should be there.
The script will prompt you to enter the Qt instalation root, such as C:\Qt\4.3.2 and it will do the work from there.

Currently it creates shortcuts for all the 4 tools and command prompt, and also creates a qtvars.bat which sets the environment. The makespec is hardcoded to win32-g++.

To run the script, just double-click it.

wysota
27th October 2007, 21:17
Great! I'll test it tomorrow. Unfortunately I'll be testing it with msvc, but I understand fixing the specs shouldn't be much work.

marcel
27th October 2007, 21:23
Great! I'll test it tomorrow.
It works fine for me, on Vista even, with UAC enabled. But some users have very strict security configurations (I call it paranoia) so the scripting host might be disabled.

So, if possible, someone should test it on XP too, but my opinion is that if it works on Vista with UAC it should work very well on XP.

If not, the only alternative is a native application that does the very same thing. Something like an installer.



Unfortunately I'll be testing it with msvc, but I understand fixing the specs shouldn't be much work.
Yes, just modify the line txtStream.WriteLine("set QMAKESPEC=win32-g++") with what you need, and also the comment above it. Or, edit the generated batch file.

BTW, Qt should be already compiled when you run the script :). If not, it will probably throw some runtime errors. I didn't exactly handled them all.:)

wysota
28th October 2007, 09:58
I wonder if it's possible to auto detect the specs like Qt does. The script could then be extended to find it itself.

marcel
28th October 2007, 10:07
What do you mean? Qt knows because it's reading the QMAKESPEC env variable.

wysota
28th October 2007, 11:42
What do you mean? Qt knows because it's reading the QMAKESPEC env variable.
I mean to be able to auto detect the specs from within the script to set the variable in the first place. If QMAKESPEC is not set, I know qmake tries (and often manages) to detect it. Maybe the script could use it somehow... but it would require qmake to dump the information somewhere, maybe it does...

jpn
28th October 2007, 12:15
Perhaps "qmake -query (http://wiki.qtcentre.org/index.php?title=Undocumented_qmake#Undocumented_mo des)" and/or $QTDIR\.qmake.cache could help somehow? Basically it should be enough to ask for the location of qmake.exe and everything else could be then figured out.. ;)

wysota
28th October 2007, 14:06
Under Linux in the specs directory there is a soft link called "default" that points to the default specs. I don't know if there is anything similar on Windows, but that could be a way to detect the specs.

If we can't make it all happen from within a script, maybe a small statically compiled app using QWizard would be an option as well...

marcel
28th October 2007, 14:07
Perhaps "qmake -query (http://wiki.qtcentre.org/index.php?title=Undocumented_qmake#Undocumented_mo des)" and/or $QTDIR\.qmake.cache could help somehow? Basically it should be enough to ask for the location of qmake.exe and everything else could be then figured out.. ;)
I don't think we can use that... qmake -query QMAKE_MKSPECS only gives you the path where the make specs are located.



but it would require qmake to dump the information somewhere, maybe it does...
Maybe have the script output a test program and then call qmake and parse its output?
I don't really trust this method. What if qmake can't tell the correct make spec?

What do you think about letting the user choose the make spec/compiler in the script interface?

marcel
28th October 2007, 14:16
Under Linux in the specs directory there is a soft link called "default" that points to the default specs. I don't know if there is anything similar on Windows, but that could be a way to detect the specs.

If we can't make it all happen from within a script, maybe a small statically compiled app using QWizard would be an option as well...
I thought of this too.
I think I'm gonna make a wizard that also let's you fully configure, compile and install Qt Open Source.
I don't know if I'm gonna write it with Qt or when it's gonna be ready, but I hope sometime soon.

wysota
28th October 2007, 14:19
What do you think about letting the user choose the make spec/compiler in the script interface?
Yes, that's an option too. If it can't detect the platform itself, it can fall back to asking the user.


I think I'm gonna make a wizard that also let's you fully configure, compile and install Qt Open Source.

I thought of this too, but didn't have time to start working on it and also there is a problem with switches changes between different versions. If you wanted help, I'd be willing to provide it.

marcel
28th October 2007, 15:04
Ok, just had a quick look at the qmake sources.
It expects the user to provide the make spec either as a qmake option( -spec or -platform ) or in the QMAKESPEC environment variable. If it cannot find it this way, it takes the default, which is located in QTDIR/mkspecs/default. The problem is that in the opensource version this folder does not exist. In the version precompiled for mingw it exists and it is the same as win32-g++ and for the commercial versions is set according to the msvc version of the distribution.
If it cannot find it in the default directory error it displays an error message:


if(cmd & ReadConf) { // parse mkspec
QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec);
QStringList mkspec_roots = qmake_mkspec_paths();
debug_msg(2, "Looking for mkspec %s in (%s)", qmakespec.toLatin1().constData(),
mkspec_roots.join("::").toLatin1().constData());
if(qmakespec.isEmpty()) {
for(QStringList::ConstIterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
QString mkspec = (*it) + QDir::separator() + "default";
QFileInfo default_info(mkspec);
if(default_info.exists() && default_info.isDir()) {
qmakespec = mkspec;
break;
}
}
if(qmakespec.isEmpty()) {
fprintf(stderr, "QMAKESPEC has not been set, so configuration cannot be deduced.\n");
return false;
}
Option::mkfile::qmakespec = qmakespec;
}
So I think it is ok and enough to provide a dropdown or a list with all the makespecs available on windows and let the user choose from them



...and also there is a problem with switches changes between different versions
No problem whatsoever. VS also has the option to switch between different Qt installations, but it does it internally.
It is just a matter of setting the environment variables to the desired installation.

wysota
29th October 2007, 09:24
No problem whatsoever. VS also has the option to switch between different Qt installations, but it does it internally.
It is just a matter of setting the environment variables to the desired installation.

No, I meant something else. Configuration options change between versions. To avoid creating a new installer for each new version, the software should be able to auto detect those switches and be able to handle them without rebuilding the installer.

marcel
29th October 2007, 09:46
Yes, I see now. The problem with this is that the options are stored inside configure, which is an executable(vs a script on linux).

I don't think there is a problem in creating a new version of the installer. Qt releases are not that often and I think it is normal to update the installer to handle the new qt version.

Maybe the options together with their descriptions should be stored in an external file, which should be updated with every qt release, while keeping the options for the older releases. This way the installer doesn't have to be rebuilt.

wysota
29th October 2007, 10:08
You can always run configure -help and inspect the options, so an external file is not that important. The problem is you have to think about handling those options afterwards :) The simplest solution is to just... ignore new switches or give a list of options to enable/modify them at the end of the configuration process and I think it's a good solution for a start.

marcel
29th October 2007, 10:32
You can always run configure -help and inspect the options, so an external file is not that important. The problem is you have to think about handling those options afterwards :) The simplest solution is to just... ignore new switches or give a list of options to enable/modify them at the end of the configuration process and I think it's a good solution for a start.
I'll think about it. I will choose the solution which seems most fit on a long term.
I think I will start this project this week, but I don't know when it's gonna be ready. Hope it won't take more than two weeks.