PDA

View Full Version : unable to make static builds on windows



mchome
14th July 2012, 08:52
I've developed a small application using Qt Creator 2.4.1 (based on Qt 4.7.4).
I want to deploy it for Windows to several friends of mine that do not use Qt, and want to make the process simple, so I strongly prefer static linking (a single exe file containing everything needed).

Qt documentation says:

****
Before we can build our application we must make sure that Qt is built statically. To do this, go to a command prompt and type the following:
cd C:\path\to\Qt
configure -static <any other options you need>
****

Unfortunately I searched my entire hard disk and did not find any "configure" executable. The PC had Win7 OS.
Since this looked rather crazy, I repeated the search for "configure" on another PC, having a different operating system (Win XP), and the same Qt creator/Qt version installed, but the result was the same.

I searched the Qt forum for anyone having a similar problem in the forum, but did not find anyone.

Some people in the forum mention ways to require static build without resorting to the configure command, just adding something in the .pro file (a solution that I would prefer), but none that I tried worked.


Can someone help?
Thanks

Zlatomir
14th July 2012, 09:16
Download the Qt framework source code (that will contain configure.exe).

mchome
14th July 2012, 12:14
ehm...
I downloaded source files and got configure.exe.
I tried
configure -static
and configure complained about not specifying the platform. Configure itself suggested reading "README" file to get information about the available platforms.
Since no README file exists in the directory in which configure resides, I searched all the qt_sdk tree and found as many as 146 README files!

I tried
configure -static -platform win32
but it didn't work.

Can I ask you the name of "platform" variable for win32 systems, or where I can find a list of platforms?

Thanks again.

wysota
14th July 2012, 12:46
It depends on the compiler you are using. You should probably use win32-mingw or something like that. Basically you need to enter the name of one of the subdirectories of the mkspecs directory.

mchome
14th July 2012, 15:12
sorry for being so slow in learning this configuration task. This is the Qt feature that gives me the biggest problems.

I've issued:
.\configure -static -platform win32-msvc2010

This command did something but ended with the following message:

WARNING: Using static linking will disable the use of plugins.
Make sure you compile ALL needed modules into the library.
Creating qmake...
execute: File or path is not found (nmake)
execute: File or path is not found (nmake)
Cleaning qmake failed, return code -1

So it looks like it did not find nmake. Indeed the only nmake.exe in my PC is in the directory
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
that might not be in the search path.

Should I add this to the search path?
Is it possible that just configuring for static build requires tampering so much with paths and directories?


The Qt instructions for preparing for static build say that I should also issue:
.\nmake sub-src
I don't understand the effects of this command. I just tried to issue it blindly.

The result was (I translate from Italian language):

NMAKE : fatal error U1073: impossible to create 'sub-scr'
Stop.

So my problems are:
1) what to do to make configure to prepare Qt for static building?
2) how about that "nmake sub-src"?

I thank everyone in advance for any help.

wysota
14th July 2012, 15:21
configure.exe is not a magic wand nor a crystal ball. If it needs some tool, you have to tell it where to find it.



I just tried to issue it blindly.
Then maybe you should open your eyes :) There is a difference between "sub-scr" and "sub-src".

mchome
14th July 2012, 17:37
ok, ok.
Maybe I should be smarter, but it seems to me that:

1) The Qt documentation suggests to use configure without telling that if you did not downloaded sources you will not have it available (if none did not tell me I could never figure out; I thank Zlatomir for this)

2) configure asked me about the platform name, but did not tell me where to find a list of possible platforms. If you did not suggest the trick I should have to scroll through 146 files to find the right name

3) Now configure does not tells precisely what its problem is. I can only imagine that adding VC to the search path might help. I must get back in my memory to a couple of decades ago, when I used MS-DOS, to remember how to add a new directory to the search path. I think of search paths as a residual from the old past.

Even though in general I admire the Qt programmers for what they've been doing during the years and the quality of Qt, I feel that the way configure works is a residual from the past and should be substituted with a gui-based piece of software. As a fall-back, at least detailed instructions on the way it operates should be available, but I could not find them.

I will try to solve my problem using what kind people like you have told me.
In case I will not succeeded I will ask for help again.

wysota
14th July 2012, 18:00
1) The Qt documentation suggests to use configure without telling that if you did not downloaded sources you will not have it available (if none did not tell me I could never figure out; I thank Zlatomir for this)
It also doesn't tell you to turn on the computer before you start compiling. I think it is pretty safe to assume that a software developer knows that source code is required to do compilation. Personally I think it also applies to other areas of life, like you need to have a car do drive it or have food to eat it.


2) configure asked me about the platform name, but did not tell me where to find a list of possible platforms. If you did not suggest the trick I should have to scroll through 146 files to find the right name
Trust me, it's there somewhere. Maybe not reported by configure but I'm pretty much sure it's somewhere in the docs. Otherwise how could I know it?


3) Now configure does not tells precisely what its problem is.
It tells you precisely what the problem is: "execute: File or path is not found (nmake)".

I can understand you expect to have a magic button that will do everything for you but then I'd expect you'd be willing to pay someone for giving that button to you. Since Qt supports a large number of platforms, you can't expect its developers to build a magic button for every possible combination of programming environments as part of their daily work. Otherwise we'd probably have not much apart just the buttons.


I can only imagine that adding VC to the search path might help.
Then don't imagine, learn your tools.


I must get back in my memory to a couple of decades ago, when I used MS-DOS, to remember how to add a new directory to the search path.
Or you can read Visual Studio documentation pointing you to a script that Microsoft developers prepared for you in case you wanted to use MSVC from the command line and not using a magic button.


I think of search paths as a residual from the old past.
That's probably why you're having problems now. If it were a residue then you wouldn't have to use search paths now, would you?


Even though in general I admire the Qt programmers for what they've been doing during the years and the quality of Qt, I feel that the way configure works is a residual from the past and should be substituted with a gui-based piece of software. As a fall-back, at least detailed instructions on the way it operates should be available, but I could not find them.

It may come as a shock to you but your problems have nothing to do with Qt. I would assume this is all because that's probably the first time you have to do something more complex than checking ip of your computer using CLI.

But let's assume you're right and focus on each sentence you wrote:


should be substituted with a gui-based piece of software
How would you use that gui-based piece of software on a headless machine? Maybe instead there should be two tools -- one CLI based for regular people (including those wanting to do something on a headless machine) and another for people who need to have a button to push? I assume that if a dialog box popped up telling you nmake couldn't be found, it would be much more informative for you than if that message is written in a window that has a black background. A GUI application certainly wouldn't magically find nmake for you.


As a fall-back, at least detailed instructions on the way it operates should be available, but I could not find them.
Which doesn't mean they are not there.

mchome
14th July 2012, 22:06
wysota,
I thought forums were to discuss technical things and help each other.
If your purpose is to spend time offending people, please dedicate your time on forum to others that might like this more than I do.

In case I ask something other, please, be so kind of ignoring me.

Zlatomir
15th July 2012, 01:43
You can (and i think it is strongly recommended to) use the shortcut that Microsoft provides (instead of cmd and manually add paths): Start->All Programs->VS_VER***->VS_Tools-> Visual Studio Command Prompt and this will set-up for you the paths needed so that you can execute nmake and VS tools from that already set-up cmd. You can run everything from there (including navigation to source and run configure and if i remember correctly it can even detect the platform if you run from here, but i'm not sure about that ;) )

wysota
15th July 2012, 02:07
I thought forums were to discuss technical things and help each other.
True, however if you come here and blame a tool (be it Qt, visual studio or whatever else) that it is the fault why you can't complete a certian task and that everything is wrong, should be different and then you surely could spend your precious time on some more interesting tasks, while in reality you're the only one to blame, then I reply the way I just did. Face the truth, after programing (or elsewhere having used a computer) for "a couple of decades" where a couple of decades ago most things were done using CLI, you shouldn't have any problems here. I have been programming for about 21 years, went through numerous systems and languages, starting with BASIC and LOGO on 8 bit Atari, through AMOS, AREXX, Pascal, C, m68k assembly on Amiga and then a couple more languages, both general purpose and scripting, mainly on Linux and Solaris I would still first blame myself for failure before assuming a tool to be faulty (especially if hundreds of thousands of people have been using it with success). Having seen many tools -- better and worse, I can say configure is not any less standard than other tools I have used throughout my life. If you don't like that you have to add some directories to the search path then blame the operating system you are using -- file a complaint to Redmond that they still heavily rely on "residual" solutions. If you have a better way of resolving program paths then maybe you can sell it to them and earn big money to afford paying someone for things you're not willing to do yourself.

If you think I'm rude then think how rude you were to say the things you have said.

If you haven't seen this brochure then please spend 10 minutes reading it, especially the paragraph I linked to (as well as the one directly following it): http://www.catb.org/~esr/faqs/smart-questions.html#keepcool

Cheers!

mchome
15th July 2012, 14:52
wysota,
In all my messages I always tried not to be over critic towards Qt, that I use with amusement and success, and... even for free!

I like Qt a lot. But this does not mean that I'm obliged to consider every piece of the Qt-related software and documentation is perfect. I think that non enthusiastic words are part of a technical discussion.

You took some of my words as strong and unthoughtful criticism, but I did not intend so. Also misunderstanding could happen in forums and, I believe, must be considered a possibility when reacting.
I could try to explain even better my words, but in that case you and me will lose valuable time.

In my opinion my words did not justify being attacked that way. I think so even after having read your link, that however was interesting and nice to read. It seems to me that I did not lose my temper, just asked not to be treated as a stupid and un-respectful person, that I think I'm not.

BTW, after fixing the path issue I've come across new difficulties, and therefore maybe I will start a new thread on them. So you will have new chances of attacking me! :)

MC

wysota
15th July 2012, 15:06
I like Qt a lot. But this does not mean that I'm obliged to consider every piece of the Qt-related software and documentation is perfect.
Nobody says you should. But you should be very sure of your ground if you start being critical about something. I'm sorry to say that but in my opinion this time you were not sure enough.


I could try to explain even better my words, but in that case you and me will lose valuable time.
I'm already investing my valuable time to help people here so I don't mind discussing. It is you who has to decide if you want to spend your valuable time on sharing your point of view.


In my opinion my words did not justify being attacked that way.
You seem to have felt offended by me saying you didn't try hard enough or that you lacked some basic knowledge. I have no idea what's so offensive in saying so. I really see no point in writing something that has already been written and what you should have read as a mandatory lecture while starting to use some tool. I know currently people are expecting maximum profit with minimum investment on their part but it doesn't mean I have to share or even accept their point of view. I expect people to have to learn on their own instead of relying that somebodey does all the research for them (not talking about you, just in general).


BTW, after fixing the path issue I've come across new difficulties, and therefore maybe I will start a new thread on them. So you will have new chances of attacking me! :)
I would suggest to continue this thread instead of starting a new one.

mchome
16th July 2012, 19:42
The reason why I intended to make static build of my programs was basically a consequence that I'm making in Qt a cross-platform version of a program that I’ve created in 1998, and that I’ve being maintaining since then. That program was created for win32 only, under Borland C++ Builder.
The exe size, when the program is built statically with Borland, is 1MB, while in the combined size of exe and needed dll’s in Qt is around 10 MB.
Differently from 1998, today 10 MB are a very poor thing. Nevertheless I tend to consider disk space always a valuable thing, and therefore I tried to make static build also with Qt to reduce program footprint.

But now I realize that doing this requires a full compilation of all Qt sources. That, in turn, implies that all the pieces of the puzzle must be at the right place (source files, libraries, compilers, support files from Microsoft SDK, etc.), and this is not easy, especially because configure.exe is intended for experts and is not fully documented (as far as I could find).

Now I revise my reasoning. To have to distribute just 9 MB more maybe is not worth struggling for several other days, in which sure also people from the Qt forum must be involved.
For the time being I’ve decided therefore to live with those 9 MB more and stick with the standard Qt build.
For the future, who knows? Will Qt 5 have a different mode for creating static libraries? We will see next autumn. Will I have other needs that will require rebuild of Qt and use to configure? Maybe.

I thank again all people that has helped me to reach the present point in which I'm more aware about how the Qt system in general, and configure.exe in particular, work.
Even the “animated discussions” with you, wysota, in the end turned nice

MC