Hello,
the problem is "QWidget: Must construct a QApplication before a QPaintDevice".
Please read below

on win32/vs2008 and linux32/g++4.4,
I build static libraries and an executable/binary that links against those static libraries.

I have a "plot" static library( plot.lib or libplot.a ) that includes a main.cpp translation unit.
This defines a namespace-scope variable

Qt Code:
  1. namespace NS1 { namespace NS2 {
  2. int argc_for_qapp=0;
  3. QApplication app(argc_for_qapp, 0);
  4. }
  5. }
To copy to clipboard, switch view to plain text mode 

so the symbol NS1::NS2::app is the variable.

in another translation unit in "plot", there is

Qt Code:
  1. namespace NS1 { namespace NS2 {
  2. extern QApplication app;
  3.  
  4. void f()
  5. {
  6. ...
  7. app.exec();
  8. }
  9.  
  10. }}
To copy to clipboard, switch view to plain text mode 


There is the application's main.cpp that calls the function f().

As I understand there is no guarantee of the initialization of globals between translation units, but there is a guarantee that all of them are initialized before the main function.

In Debug there is no problem, in Release there is the problem:
"QWidget: Must construct a QApplication before a QPaintDevice"

In Release vs2008, I made sure the linker options for the executable that includes, in Linker/Optimization/References => "Keep Unreferenced Data"
Linker/Optimization/Enable COMDAT Folding => "Do Not Remove Redundant COMDATs "

so the reference to NS1::NS2::app that is in another translation unit is not removed.

Again in debug mode, this works fine.
in release/linux32/g++4.4, same error.

rds,