PDA

View Full Version : Deploying a Qt application



seub
11th October 2012, 04:23
Hi everyone,

Total newbie to Qt here ;) Also, actually, to software development in general. I am a young mathematician who has just completed writing his first "scientific" program using Qt. I hope you'll forgive me if my questions sound silly (and I am aware that this has been asked several times, and that there's documentation on this).

I've designed this program using Qt Creator 2.5.0 (based on Qt 4.8.1 64 bits) on my PC under Linux (Ubuntu 12.04 64 bits). It works very well, but trying to figure out how to deploy the app for the past couple days has been a rude awakening. I didn't expect I'd be so lost and nowhere at this point.

So, my project is not very sophisticated, it consists of approximantely 40 headers and 40 sources, a qrc containing a few png and html files, and I'm using a bunch of Qt classes which I guess are the most classical ones. Now I'd like to make this available in the simplest possible way for Linux, Mac and Windows users (mostly fellow mathematicians I guess, but those can ignore the first thing about computers). I'm tempted to give it up and ask people to install qt and compile my files, but I hope i change my mind.

So, this is where I'm at now, please correct me if needed:
-For Linux users, I should probably compile my program using static linking (?)
Problem1: see afer.
Q1: I guess I want to compile two versions, 32 and 64 bits? How well are they going to work on different distributions?
Q2: Sould I make a deb file or something?

-For Windows users,
Problem2: I've tried to cross-compile the app for windows from my PC using wine and mingw32, following every tuto I could find on the web, but I never got it to work; there always seemed to be an error with the qmake.conf file or something. I've come to the conclusion that even though I don't have a PC with Windows on it, I should just find one (I guess I would need one anyway to test the app) and compile my source there.
Q3: Suppose I manage to do that. Will my exe file work on all Windows computers?
Q4: Should I try to create an installer (is it going to drive me crazy as well)?

-For Mac users,
Q5: I guess it's gonna be pretty much the same as for Linux case? (the advantage is, I do have a Mac at home).


Okay, now here's my specific problem when I tried to build my project statically. First here's what I did:
1. I downloaded the Qt4.8.3 sources and built them statically (strangely, the compiler(s) don't seem to care that I told them -prefix <some folder> (in the ./configure code line), it just compiled everything in the sources folder apparently (I can tell you what I did in more details if necessary).
2. I changed the options in Qt creator to compile using the static version of Qt. I get a warning telling me "qmlviewer not installed" (don't know if that matters).
3. Because I pretty much mixed different tutos read here and there, I tried to add "CONFIG+=STATIC" in the pro file, or adding some LIBS there, or... but that didn't seem to affect the result at all.
What I get is a file that seemed to work at first: It was 15Mb instead of 1Mb previously, it no longer required the two Qt dependencies that it used to (checked that with ldd command line), and the program worked... apparently. First i notices in Qt Creator's Application output that I kept getting Qt errors: "Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion `GTK_IS_WIDGET (widget)' failed". Mmm... doesn't sound too good. Even worse, everything seems to work except my help menu that doesn't manage to show itself and makes the program pretty much freeze. And the output shows:
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x0 and sometimes QNativeImage: Unable to attach to shared memory segment. If you need to know, the help menu is a simple widget containing a QTextBrowser (and a couple buttons) that shows an html file with some png images.

I'd really appreciate some help here, feeling a bit alone in the dark! Thanks in advance,

Seub

PS: I wouldn't mind giving you my sources if you want to try something, but the zip file is 750kb and the max here seems to be 244kb

Gokulnathvc
25th October 2012, 12:59
Try following these::

1. Install QtSDK (2009.05)

2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
QMAKE_LFLAGS = -static -enable-stdcall...

4. Save and close this file.

5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

8. When finished, relog or reboot.

9. Open a command prompt.

10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

12. When it asks which edition you want to use, enter "o" for open source.

13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

14. When that finishes, enter the following: mingw32-make sub-src (or) nmake sub-src

15. Go out to dinner, this will take a while (took between 1-2 hours for me).

16. When this finishes, open your project in the Qt Creator.

17. Double-click the project (.pro) file to open it in edit mode.

18. Add the following line: CONFIG += static

19. qmake Hello.pro
nmake release (or) mingw32-make release

20. Navigate to your release directory and voila! Your standalone executable should be there.

ChrisW67
27th October 2012, 23:28
So, this is where I'm at now, please correct me if needed:
-For Linux users, I should probably compile my program using static linking (?)
Problem1: see afer.
Q1: I guess I want to compile two versions, 32 and 64 bits? How well are they going to work on different distributions?
Q2: Sould I make a deb file or something?

No, I'd use shared Qt and either ship the libraries with your binary or rely on the end-user to install Qt libraries. The deployment page (deployment-x11.html#shared-libraries) explains how to launch your application form a shell script so that the libraries are found. You can wrap it in one of the common Linux deployment package or just ship a gzipped tar file that just needs to be extracted.

Most 64-bit Linux installs are capable of running a 32-bit app, so I would try that first.



-For Windows users,
Problem2: I've tried to cross-compile the app for windows from my PC using wine and mingw32, following every tuto I could find on the web, but I never got it to work; there always seemed to be an error with the qmake.conf file or something. I've come to the conclusion that even though I don't have a PC with Windows on it, I should just find one (I guess I would need one anyway to test the app) and compile my source there.
Q3: Suppose I manage to do that. Will my exe file work on all Windows computers?

Yes, XP up. If you build a 32-bit app it will run on either 32- or 64-bit systems. You can develop in a virtual machine if that is easier.


Q4: Should I try to create an installer (is it going to drive me crazy as well)?

Yes, this would normally be expected by Windows users, but you can do a zip bundle that just needs to be unzipped. The layout of a Windows deployment is covered many, many times in this forum.



-For Mac users,
Q5: I guess it's gonna be pretty much the same as for Linux case? (the advantage is, I do have a Mac at home).

You would normally build an App bundle. I cannot really help here, having never done it in anger.

sarbh20ss
3rd October 2013, 12:40
Following above discussions....I tried shared library approach.
I am working on windows XP, using Qt 4.8.5, wince SDK 5.0, Visual Studio 2008.
I followed this link:
http://doc.qt.digia.com/4.7/deployment-windows.html and
configured my Qt with this command :
configure -shared -platform win32-msvc2008 -xplatform wincewm50pocket-msvc2008
Then ran command showed on prompt of Visual Studio 2008.
Everything went without error.

Then as described in above link, i tried to build 'plugandpaint' example. I built without errors but no file named 'pnp_basictools.dll' was created.
Then I used dependency walker for 'plugpaint.exe'. It shows QTGUI4.DLL, QTCORE4.DLL and COREDLL.DLL are not found. I found QTGUI4.DLL and QTCORE.DLL but not the COREDLL.DLL on my computer. I googled for this file and came to know that it is one of the wince core files similar to user32.dll.
I have wince5 sdk installed on my computer but no 'COREDLL.DLL'....how is this?
How to solve this problem?
What I am doing wrong?

harvey_slash
3rd October 2013, 13:15
I downloaded an older version.
worked fine.

sarbh20ss
3rd October 2013, 13:47
Hey thanks for reply...
U mean older version of visual studio???

harvey_slash
3rd October 2013, 15:23
I meant older version of Qt.
I use 4.8
why do you need that ?
I used this.
mingw32-make
(this was after configuring)
you need your environment variables set from the control panel.
then use (this is what I have used)
configure -platform win32-g++ -release -static -no-exceptions
||||||
(it should show lots of 'doing stuff')
then use
mingw32-make

sarbh20ss
4th October 2013, 05:33
Well thanks for your advice.
As I said I followed this link to install Qt for wince.

http://qt-project.org/doc/qt-4.8/install-wince.html

I found these links yesterday :
http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler/
http://www.formortals.com/how-to-statically-link-qt-4/

So I guess I have to build Qt statically. Well I am confused now. Please tell me if I am doing something wrong?
I would appreciate any advice that will point me in right direction.