Seub
Seub

Reputation: 3192

Qt errors after static compilation

I'm writing a Qt program with Qt creator (v2.5.0 Based on Qt 4.8.1 (64 bit)) on a computer under Ubuntu 12.04 64 bits. It works fine on my computer and I'm happy about it.

But now I want to deploy my app, so I decided to try to do build my project statically. In order to do that, I compiled Qt statically (from the 4.8.3 sources), I changed the qmake choice in Qt creator (replaced it with the "static" one), and I selected "static build" in build settings.

At first it seemed to work perfectly: my new executable file was 15Mb (instead of its usual 1Mb) and when I did ldd ./myApp to check the dependencies, there were no more libQtGui.so.4 nor libQtCore.so.4, and the program seemed to work okay.

Then I realized Qt Creator was constantly yelling in the Application output:

"Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion `GTK_IS_WIDGET (widget)' failed"

That can't be too good, what's going on? Worse, when I try to load the help menu of my program, somehow it doesn't manage to open the window and sort of freezes. The help menu is just a widget containing a QTextBrowser (which displays an html file with a couple png pics) and a few buttons. I get the following error repeatedly in the app output:

**X Error: BadDrawable (invalid Pixmap or Window parameter) 9 Major opcode: 62 (X_CopyArea) Resource id: 0x0**

and one (or more?) QNativeImage: Unable to attach to shared memory segment.

It might have something to do with the fact that when I added the static version of qmake (in Qt options, Build & Run, Qt versions tab), I get the warning: "No qmlviewer installed". I have no idea.

Anyway, I'm kind of disappointed and depressed, deploying the app is much harder than I expected and incredibly annoying. Does anyone know how to fix this?

While I'm here, I have a few other small questions:

  1. Does it matter that Qt creator does qmake myApp.pro -r -spec linux-g++ and make -w instead of just qmake and make?
  2. I read in several places to add LIBS in my .pro file, also I read in one place I should write CONFIG += static, Qt official doc says to do things slightly differently (but for once, I find it very badly written and confusing), but all of this doesn't seem to do anything. Does it matter?

Thank you very much in advance for your help!

Upvotes: 0

Views: 1608

Answers (2)

albfan
albfan

Reputation: 12940

Warning: X Error: BadDrawable (invalid Pixmap or Window parameter)

is a known problem for Qt apps

http://www.iwillfolo.com/quick-fix-one-kdes-common-xorg-errors-x-error-baddrawable/

it is fixed using

export QT_X11_NO_MITSHM=1

or

QT_X11_NO_MITSHM=1 yourapp

QT_X11_NO_MITSHM – stops Qt form using the MIT-SHM X11 extension.

More info here:

https://en.wikipedia.org/wiki/MIT-SHM

Upvotes: 1

Mevin Babu
Mevin Babu

Reputation: 2475

It might have something to do with the fact that when I added the static version of qmake (in Qt options, Build & Run, Qt versions tab), I get the warning: "No qmlviewer installed". I have no idea.

It has nothing to do with adding the static version of qmake and getting the warning "No qmlviewer installed" is normal

Does it matter that Qt creator does qmake myApp.pro -r -spec linux-g++ and make -w instead of just qmake and make?

No, its fine

I read in several places to add LIBS in my .pro file, also I read in one place I should write CONFIG += static, Qt official doc says to do things slightly differently (but for once, I find it very badly written and confusing), but all of this doesn't seem to do anything. Does it matter?

I usually compile my project with CONFIG +=static\ release

And you have to add LIBS+= to your project only if your loading any dynamic library files or other library files which are not in the system path.

Upvotes: 1

Related Questions