I am trying to make a Qt 5 application with several Qwt widgets, but I see a segmentation error in Qt code as soon as I try to link the Qwt libraries. I use a very simple Qt program that only displays a blank window:
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(250, 150);
window.setWindowTitle("Simple example");
window.show();
return app.exec();
}
This works fine when compiling. Problems begin as soon as I add LIBS += -lqwtto my .pro file. It will still compile, but segmentation errors when I try to run it, even without calling the Qwt code.
Backtrace:
Program received signal SIGSEGV, Segmentation fault.
QList (this=0x3ea60da418 <QPrinterInfoPrivate::shared_null+24>) at ../../src/corelib/tools/qlist.h:121
121 inline QList() : d(&QListData::shared_null) { d->ref.ref(); }
(gdb) bt
#0 QList (this=0x3ea60da418 <QPrinterInfoPrivate::shared_null+24>) at ../../src/corelib/tools/qlist.h:121
#1 QPrinterInfoPrivate (name=..., this=0x3ea60da400 <QPrinterInfoPrivate::shared_null>) at painting/qprinterinfo_p.h:71
#2 __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at painting/qprinterinfo.cpp:35
#3 _GLOBAL__sub_I_qprinterinfo.cpp(void) () at painting/qprinterinfo.cpp:163
#4 0x0000003e9c20f2ea in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffddb8, env=env@entry=0x7fffffffddc8) at dl-init.c:82
#5 0x0000003e9c20f3d3 in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:34
#6 _dl_init (main_map=0x3e9c421168, argc=1, argv=0x7fffffffddb8, env=0x7fffffffddc8) at dl-init.c:130
#7 0x0000003e9c20122a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
As you can see, segfault happens in Qt code without using the code in main.cpp. What causes this and how to fix it?
I use Qt 5.2.0 and Qwt 6.1.0 on Fedora 20, both from repositories.