Results 1 to 6 of 6

Thread: QWT integration with static QT build

  1. #1

    Default QWT integration with static QT build

    Hello.

    I'm working on a small scientific Qt project for experimental data handling data visualization. Since this project is mostly designated for Windows users, I intend to create a statically linked distribution of the final product, so as not to burden the users. I've built Qt statically according to these instructions. I've made some minors changes to the configuration call (for instance, I excluded the Webkit plugin due to some compilation difficulties), but in general the whole build seems to be working fine. I can easily create standalone builds for simple Qt applications (typical executable is about 8-9 MB large). I have also compiled Qwt (with its defaults configuration) and I can run the Qwt examples and I can import Qwt to my own projects. My problem is that I can't seem to combine both the static Qt build and Qwt. I am able to build a Qwt containing project statically and create an executable file, but its execution always leads to an error (A pop-up widow: "Microsoft Visual C++ Runtime Library: This application has requested the Runtime to terminate it an unusual way. Please contact the application's support team for more information", and "Invalid parameter passed to C runtime function." in the output). Note that a default (dynamic ?) build of the same application always succeeds. What might be the problem?

    Thanks in advance.

  2. #2

    Default Re: QWT integration with static QT build

    I'm bumping this thread once again, since I'm still faced with the same problem. I'll try to be more specific. After my previous atempts I tried to build a static version of QWT (by disabling the "#QWT_CONFIG += QwtDll" option during installation) but I still can't build a static release of a QWT program
    Take, for instance, this simple example. After a few slight modifications my *.pro file looks like this:
    Qt Code:
    1. include( C:/qwt-6.0.1/qwt.prf )
    2. QT += core gui
    3. CONFIG += qt
    4. TARGET = CppQwtExample1
    5. TEMPLATE = app
    6. SOURCES += main.cpp
    7. static {
    8. CONFIG += static
    9. DEFINES += STATIC
    10. }
    To copy to clipboard, switch view to plain text mode 
    and my main file looks like this:
    Qt Code:
    1. #include <cmath>
    2. #include <QApplication>
    3. #include <qwt_plot.h>
    4. #include <qwt_plot_curve.h>
    5.  
    6. int main(int argc, char **argv)
    7. {
    8. QApplication a(argc, argv);
    9. QwtPlot plot(QwtText("CppQwtExample1"));
    10. plot.setGeometry(0,0,640,400);
    11. plot.setAxisScale(QwtPlot::xBottom, 0.0,2.0 * M_PI);
    12. plot.setAxisScale(QwtPlot::yLeft,-1.0,1.0);
    13. QwtPlotCurve sine("Sine");
    14. std::vector<double> xs;
    15. std::vector<double> ys;
    16. for (double x = 0; x < 2.0 * M_PI; x+=(M_PI / 10.0))
    17. {
    18. xs.push_back(x);
    19. ys.push_back(std::sin(x));
    20. }
    21. sine.setSamples(&xs[0],&ys[0],xs.size());
    22. sine.attach(&plot);
    23. plot.show();
    24. return a.exec();
    25. }
    To copy to clipboard, switch view to plain text mode 

    I can build it just fine with the usual 4.7.0 release option. A static release, on the other hand, fails. I get a:
    Qt Code:
    1. :: error: collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 
    linking error in build issues screen and lots of these kind of errors:
    Qt Code:
    1. C:/Qwt-6.0.1/lib/libqwt.a(qwt_text.o):qwt_text.cpp:(.text+0x22b): undefined reference to `_imp___ZN4QPenC1EN2Qt8PenStyleE'
    2. C:/Qwt-6.0.1/lib/libqwt.a(qwt_text.o):qwt_text.cpp:(.text+0x245): undefined reference to `_imp___ZNK4QPeneqERKS_'
    3. C:/Qwt-6.0.1/lib/libqwt.a(qwt_text.o):qwt_text.cpp:(.text+0x261): undefined reference to `_imp___ZN6QBrushC1EN2Qt10BrushStyleE'
    4. C:/Qwt-6.0.1/lib/libqwt.a(qwt_text.o):qwt_text.cpp:(.text+0x27b): undefined reference to `_imp___ZNK6QBrusheqERKS_'
    5. C:/Qwt-6.0.1/lib/libqwt.a(qwt_text.o):qwt_text.cpp:(.text+0x28d): undefined reference to `_imp___ZN6QBrushD1Ev'
    6. ...
    7. C:/Qwt-6.0.1/lib/libqwt.a(qwt_spline.o):qwt_spline.cpp:(.text$_ZN7QVectorIdEaSERKS0_[QVector<double>::operator=(QVector<double> const&)]+0x31): undefined reference to `_imp___ZN11QVectorData4freeEPS_i'
    8. collect2: ld returned 1 exit status
    9. mingw32-make[1]: *** [release\CppQwtExample1.exe] Error 1
    10. mingw32-make: *** [release] Error 2
    To copy to clipboard, switch view to plain text mode 
    in the compile output. So my question remains - what might be the cause of this problem and what are the possible solutions to it?

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWT integration with static QT build

    Hey,

    It seems that you've messed up Qt build but I can't tell what exacly.
    I've just build Qt 4.7.4 as static and it works with Qwt without any problem.

    I need to recompile it to include gcc (now you need to distribute gcc dll with the binary) and debug libraries.
    I'll post how I've done it later, I hope that will help you.

    Note Qt 4.6.0 < x > 4.7.0 can't be compiled statically and work with UI widgets according to qt bug database.

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWT integration with static QT build

    Ok, so here's what I've got:

    Windows 7 64bit running Qt 4.6.3 (installed, not compiled).

    I've downloaded Qt 4.7.4 source, changed two lines in qt-everywhere-opensource-src-4.7.4\mkspecs\win32-g++\qmake.conf to look like that:
    Qt Code:
    1. QMAKE_CFLAGS_RELEASE = -Os -momit-leaf-frame-pointer
    2. QMAKE_LFLAGS = -static -static-libgcc
    To copy to clipboard, switch view to plain text mode 
    and compiled whole thing using:
    Qt Code:
    1. configure -release -nomake examples -nomake demos -no-exceptions -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-s60 -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -platform win32-g++ -static
    2. mingw32-make
    To copy to clipboard, switch view to plain text mode 
    Then coment out line 61 in qwt-6.0.1\qwtconfig.pri and compile it (I've done it using Qt Creator).

    In test app just add a QwtPlot object and compile. In your *.pro file you will need to add two lines:
    Qt Code:
    1. INCLUDEPATH += <path to your qwt>\\qwt-6.0.1\\src
    2. LIBS += -L<path to your qwt>\\qwt-6.0.1c\\lib -lqwt
    To copy to clipboard, switch view to plain text mode 
    after that everything should work just fine.

    Let me know if it works for you.

  5. The following user says thank you to Spitfire for this useful post:

    Matthiasabt (7th October 2013)

  6. #5

    Default Re: QWT integration with static QT build

    Thanks a lot for the feedback. I tried to build QT according to your instructions, but I still seem to have the same problem: I can either build a static non-Qwt application or a dynamically linked QWT application . The errors that appear while trying to build a static application, on the other hand, differ this time (and I actually get about 2000 of them). The build issues screen displays a lot of undefined references (qwt_plot_curve.cpp:-1: error: undefined reference to `_imp___ZN8QPainter4saveEv' etc.), and I get this:
    Qt Code:
    1. C:/Qwt-6.0.1/lib\libqwt.a(qwt_plot_curve.o):qwt_plot_curve.cpp:(.text+0x48c): undefined reference to `_imp___ZN8QPainter4saveEv'
    2. C:/Qwt-6.0.1/lib\libqwt.a(qwt_plot_curve.o):qwt_plot_curve.cpp:(.text+0x4a4): undefined reference to `_imp___ZN8QPainter6setPenERK4QPen'
    3. C:/Qwt-6.0.1/lib\libqwt.a(qwt_plot_curve.o):qwt_plot_curve.cpp:(.text+0x4e5): undefined reference to `_imp___ZN8QPainter7restoreEv'
    4. C:/Qwt-6.0.1/lib\libqwt.a(qwt_plot_curve.o):qwt_plot_curve.cpp:(.text+0x6f8): undefined reference to `_imp___ZN8QPainter4saveEv'
    5. C:/Qwt-6.0.1/lib\libqwt.a(qwt_plot_curve.o):qwt_plot_curve.cpp:(.text+0x712): undefined reference to `_imp___ZN8QPainter5scaleEd
    6. ...
    7. C:/Qwt-6.0.1/lib\libqwt.a(qwt_null_paintdevice.o):qwt_null_paintdevice.cpp:(.text+0x6e2): undefined reference to `_imp___ZN12QPaintDeviceD2Ev'
    8. C:/Qwt-6.0.1/lib\libqwt.a(qwt_null_paintdevice.o):qwt_null_paintdevice.cpp:(.text+0x712): undefined reference to `_imp___ZN12QPaintEngineC2E6QFlagsINS_18PaintEngineFeatureEE'
    9. C:/Qwt-6.0.1/lib\libqwt.a(qwt_null_paintdevice.o):qwt_null_paintdevice.cpp:(.text$_ZN18QwtNullPaintDevice11PaintEngineD1Ev[QwtNullPaintDevice::PaintEngine::~PaintEngine()]+0x10): undefined reference to `_imp___ZN12QPaintEngineD2Ev'
    10. C:/Qwt-6.0.1/lib\libqwt.a(qwt_null_paintdevice.o):qwt_null_paintdevice.cpp:(.text$_ZN18QwtNullPaintDevice11PaintEngineD0Ev[QwtNullPaintDevice::PaintEngine::~PaintEngine()]+0x15): undefined reference to `_imp___ZN12QPaintEngineD2Ev'
    11. collect2: ld returned 1 exit status
    12. mingw32-make[1]: *** [release\untitlediii.exe] Error 1
    13. mingw32-make: *** [release] Error 2
    14. The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    15. Error while building project untitlediii (target: Desktop)
    16. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 
    in the compile output.


    Added after 20 minutes:


    OK, I was a bit too hasty with my last reply here, because I, in fact, managed to cope with this linking problem. My main error (on both of my attemps) was that I compiled Qwt with the default qmake.exe and not the one from the static QT build. I know that it's a rather silly error, but I hope that my experience will be useful to others .

    Cheers.
    Last edited by DizzyMoods; 20th October 2011 at 16:31.

  7. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWT integration with static QT build

    Now I know what I've forgot to mention in the steps above

Similar Threads

  1. Build static QT + static SSL problem.
    By makzimi in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2012, 23:45
  2. Replies: 1
    Last Post: 13th January 2010, 23:35
  3. build static Qt Creator
    By rubenvb in forum Qt Tools
    Replies: 3
    Last Post: 18th November 2009, 20:16
  4. Moving from QT 4.5 shared build to QT 4.5.2 static build
    By extrakun in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2009, 09:49
  5. Can i build a static exe?
    By coder1985 in forum Qt Programming
    Replies: 3
    Last Post: 11th June 2008, 16:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.