Reputation: 93
I am currently in the process of porting one of my Qt programs from Windows to Linux. Working with Qt's useful macro's I managed to compile the program but haven't yet succeeded in making it work.
It is a program existing out of 2 libraries and a main application. On Windows it works fine and there are no windows native calls. But when I run my application I continually get a segmentation fault.
Having debugged my program I get the following result :
#0 0x00fb098a in ?? () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#1 0x00fc115d in QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#2 0x001355d3 in Communicator::init(int) () from ~/QtWorkspace/App/Communication/libCommunication.so.1
#3 0x0013f7c3 in Updater::Updater(QWidget*) () from ~/QtWorkspace/App/Updater/libUpdater.so.1
#4 0x0806a2f9 in Controller::Controller(QObject*, int, char**) ()
#5 0x08051a26 in main ()
With Controller being a part of my main application that is calling the first library(Updater) which calls the second library (Communicator). In the Communicator plenty of connect's happen but nothing different from the Windows application.
I used LD_LIBRARY_PATH to make sure the loading of the libraries went correctly, and used Qt Creator to compile my application. This all is done on a Ubuntu 12.04 and a Windows 7 operating system.
Thanks in advance !
Giriel
EDIT:
Thanks for the quick responses, I had issues with compiling in debug mode but that's now fixed. So I ran the debugger of QtCreator and found out where it goes wrong, problem is I don't see the reason. This is the code where it goes wrong:
fSocket = new QUdpSocket(this);
fSocket->bind(QHostAddress::Any, 0, QUdpSocket::DontShareAddress);
connect(fSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
The segfault is occurring in the connect as I stated already.
The problem with multiple versions of libraries is a plausible one but I thought at least QtCreator would be safe there. Also if I check with ldd I don't see any problems there.
EDIT2:
Upon request the debug results after having added the Qt sources to gdb (doesn't seem to work in QtCreator although .gdbinit is read at startup?):
#0 indexOfMethodRelative<8> (normalizeStringData=false, method=0x139efd "readPendingDatagrams()",
baseObject=0xbfffeff4) at kernel/qmetaobject.cpp:530
#1 QMetaObjectPrivate::indexOfSlotRelative (m=0xbfffeff4, slot=0x139efd "readPendingDatagrams()",
normalizeStringData=false) at kernel/qmetaobject.cpp:665
#2 0x00fc915d in QObject::connect (sender=0x825b2d0, signal=0x139f44 "2readyRead()", receiver=0xbffff160,
method=0x139efc "1readPendingDatagrams()", type=Qt::AutoConnection) at kernel/qobject.cpp:2592
#3 0x00137622 in Communicator::init (this=0xbffff160, timeOut=5000)
at ../../App/Communication/communicator.cpp:25
#4 0x00143dcc in Updater::Updater (this=0xbffff148, parent=0x0) at ../../App/Updater/updater.cpp:10
#5 0x0806b2ae in Controller::Controller (this=0xbffff120, parent=0x0, argc=1, argv=0xbffff2b4)
at ../../App/App/controller.cpp:4
#6 0x08054bbe in main (argc=1, argv=0xbffff2b4) at ../../App/App/main.cpp:18
Perhaps this could help? readPendingDatagrams() is a private slot.
Upvotes: 2
Views: 1604
Reputation: 93
I have fixed the issue myself by creating a complete new project and copying every file. As such I think the error must lie within the user file.
Thanks everyone for your suggestions !
Upvotes: 0
Reputation: 378
First, the QObject::connect
call is probably an indicator of some callback failed to be bound to a signal (callbacks/signals are Qt mechanism). It might be a result of using different Qt version on Linux than the one on Windows.
Second, you probably want to debug it under Qt Creator, it's a great tool for debugging.
Set a breakpoint on Communicator::init()
, and spot the failing connect()
call. Then compare the arguments passed to this connect()
call with what's required by the Qt version installed on your Ubuntu box. It would also be nice if you could post your Communicator::init()
code here, so people could take a look on it and help you.
Another reason might be that you are compiling with one version of Qt while shared library installed is on that box is of another version... this is just a wild guess, but it worth double-checking.
Even if it's not Qt version problem, it's always good to start investigation by looking on the failing call. It also might be that it can't find some system variables present on Windows, and is passing some empty string / NULL string, where an actual valid value is expected.
Upvotes: 3