Qt4 static compiling and odd errors with things happening before they should even exist
Always pick a title that draws in a programmer.
Anyway I'm using linux and I compiled the qt4.7.1 libs using ./configure -static -nomake demos -nomake examples -nomake tools -prefix /local/qt/qtstatic
the build and install all went fine, and I set it up in qt creator so I can build with it. Building any application works fine, however when I run the application it gives me an error.
QWidget: Must construct a QApplication before a QPaintDevice Aborted
I understand that this means a static object is trying to use a class (QPaintDevice) that needs QApplication to be called first, and since static objects are all processed before the actual application this is obviously going to fail, The first line after my main() is the QAplication, however I know that doesn’t make a difference, My .pro does contain CONFIGURE +=static, and I have defined static in the main program, Qt4 just doesn't like me.
How can I fix it so the static objects don't all go insane like this.
#include <QtGui/QApplication>
#include "microbrowse.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
microbrowse w;
w.show();
return a.exec();
}
is the main, but that's probably not important, the main is pretty much the same for all QT apps made by qt creator, except microbrowse is the name of whatever widget开发者_如何学C your working on. The widget microbrowse is the entire program, all this does is create the QApplication, and dimension microbrowse.
I think class microbrowse
contains such a object that is not possible to be statically linked. Also check your Qt build. You should have add ./configure -relase
or -debug
while configuring.
精彩评论