PDA

View Full Version : extern QWidgetList *qt_modal_stack



Alex_123
19th December 2008, 13:00
Hi. I was just wondering if it's possible to declare this variable that's used in qapplication.cpp, qapplication_x11.cpp as an extern variable and use it in my code. I need it in order to port old code I wrote for Qt3 to Qt4.

The problem is when I try to declare it as extern and then link my application, I get error that the qt_modal_stack is unresolved.

caduel
19th December 2008, 13:08
well, you can always declare it as extern.
If noone defines it, though, you end up in that error ;)

In Qt 4.4.2 such a variable is declared

extern QWidgetList *qt_modal_stack;
therefore your code should link (if you link against the right libs.

Show us your link command and the error msg, pls.

Alex_123
19th December 2008, 16:52
D:/Development/IDEs/MinGW/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directory `D:/Development/Projects/Qt4/Item_delegates'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\Item_delegates.exe debug/ComboDelegate.o debug/main.o debug/MainWidget.o debug/Painter.o debug/moc_ComboDelegate.o debug/moc_MainWidget.o -L"d:\Development\Libraries\QT4\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
debug/MainWidget.o(.text+0x96b): In function 'ZN10MainWidget10paintEventEP11QPaintEvent':
D:/Development/Projects/Qt4/Item_delegates/MainWidget.cpp:32: undefined reference to `qt_modal_stack'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\Item_delegates.exe] Error 1
mingw32-make.exe[1]: Leaving directory `D:/Development/Projects/Qt4/Item_delegates'
D:/Development/IDEs/MinGW/bin/mingw32-make.exe: *** [debug] Error 2

caduel
19th December 2008, 17:15
I'm using linux/X11... so I am not really sure about what the problem is here.
Have you checked, whether your Qt stuff in put into some namespace?
(There is the QT_BEGIN_NAMESPACE macro...)
Perhaps you can check if this variable is in the symbols of your lib (or object file). In linux you could use the nm command.

Alex_123
20th December 2008, 12:09
It appears that qt shared objects 'so' contain no symbols at all. I used nm command and it found symbols in libraries with debug name only (i.e. libQtGui.so.4.4.2.debug). Then I used "grep 'qt_modal_stack' *" command and the string was found in library libQtGui.so.4.4.2.debug. However when I tried to link with libQtGui.so.4.4.2.debug ld found no qt_modal_stack again.

caduel
20th December 2008, 12:24
maybe the symbol is not exported (newer gcc's have a "visibility" attribute...)