Results 1 to 4 of 4

Thread: port linux app to win (runtime error)

  1. #1
    Join Date
    Aug 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default port linux app to win (runtime error)

    hi,
    does anybody know which are the steps to port my linux code to win. i change the includepath and lib values in my .pro file. compiling works fine but when i start my application i get an runtime error. have a qwtPlot object that get the data to plot by a Qthread. in linux all work fine. hope somebody can help me!!!

    i use qt-4.5 and qwt-5.1 (also with qwt-5.2 i have the same problem)

    thanks in advance

  2. #2
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: port linux app to win (runtime error)

    It's impossible to help without more information. Get a debugger and find out what code causes the crash.

  3. #3
    Join Date
    Aug 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: port linux app to win (runtime error)

    I have done some tests. I get the runtime error when I instantiate the qwtPlot object in main.


    nodeplot.h
    Qt Code:
    1. #include "qwt_scale_widget.h"
    2. #include "qwt_legend.h"
    3. #include "qwt_legend_item.h"
    4. #include "qwt_plot_canvas.h"
    5. #include "qwt_plot_grid.h"
    6. #include "qwt_plot.h"
    7. #include <stdio.h>
    8. #include <iostream>
    9. #include<string.h>
    10. #include <QString>
    11. #include <QTcpSocket>
    12. #include <QtNetwork>
    13. #include <QMutex>
    14. #include <QSemaphore>
    15.  
    16.  
    17.  
    18.  
    19.  
    20. class NodePlot : public QwtPlot{
    21.  
    22. Q_OBJECT
    23. public:
    24. /* constructor */
    25. NodePlot(QWidget *parent , int portnumber , char* hostname,int node_id);
    26. const QwtPlotCurve *nodeCurve() const
    27. { return data.curve; }
    28. int getHistory(){ return this->HISTORY; }
    29. void set_params();
    30.  
    31. struct
    32. {
    33. QwtPlotCurve *curve;
    34. double* data;
    35. } data;
    36.  
    37. unsigned int ts; // timestamp
    38. char pack_str[40]; // package storage
    39. char hostname[30];
    40. int portnumber; // portnumber of data communication with the server
    41. double* timeData; // contains the values of the x-axis
    42. int node_id; // id of sender node
    43. unsigned char val; // utility var to control package ssequence in control_sequence function
    44. int dataCount; // take trace of the amount of points to plot
    45. QMutex mutex; // mutex to handle array of data to plot
    46.  
    47. protected:
    48. void timerEvent(QTimerEvent *e);
    49.  
    50. private:
    51. int HISTORY;
    52. int YMAX;
    53. int YMIN;
    54. char xTitle[30];
    55. char yTitle[30];
    56.  
    57.  
    58. };
    59.  
    60.  
    61.  
    62.  
    63.  
    64. #endif // NODEPLOT_H
    To copy to clipboard, switch view to plain text mode 

    nodeplot.cpp
    Qt Code:
    1. #include "nodeplot.h"
    2.  
    3.  
    4.  
    5. using namespace std;
    6.  
    7.  
    8. class NodeCurve: public QwtPlotCurve
    9. {
    10. public:
    11. NodeCurve(const QString &title):
    12. QwtPlotCurve(title)
    13. {
    14. #if QT_VERSION >= 0x040000
    15. //setRenderHint(QwtPlotItem::RenderAntialiased);
    16. #endif
    17. this->setCurveType(QwtPlotCurve::Yfx);
    18. }
    19.  
    20. void setColor(const QColor &color)
    21. {
    22. #if QT_VERSION >= 0x040000
    23. QColor c = color;
    24. c.setAlpha(150);
    25.  
    26.  
    27. setPen(c);
    28. //setBrush(c);
    29. #else
    30. setPen(color);
    31. setBrush(QBrush(color, Qt::Dense4Pattern));
    32. #endif
    33. }
    34.  
    35.  
    36. };
    37.  
    38. /*
    39. class to set eventually the x-axis to time scale
    40. */
    41. class TimeScaleDraw: public QwtScaleDraw
    42. {
    43. public:
    44. TimeScaleDraw(const QTime &base):
    45. baseTime(base)
    46. {
    47. }
    48. virtual QwtText label(double v) const
    49. {
    50. QTime upTime = baseTime.addSecs((int)v);
    51. return upTime.toString();
    52. }
    53. private:
    54. QTime baseTime;
    55. };
    56.  
    57.  
    58.  
    59. NodePlot::NodePlot(QWidget *parent, int portnumber, char *hostname,int node_id):
    60. QwtPlot(parent),
    61. dataCount(0)
    62. {
    63. this->HISTORY=60;
    64.  
    65. set_params();
    66.  
    67. this->data.data=(double*)malloc(HISTORY*sizeof(double));
    68. this->timeData=(double*)malloc(HISTORY*sizeof(double));
    69. setAutoReplot(false);
    70. /*
    71.   setting the vars for the tcp connection
    72.   */
    73. strcpy(this->hostname,hostname);
    74. this->portnumber=portnumber;
    75. this->node_id= node_id;
    76. this->val=0;
    77. plotLayout()->setAlignCanvasToScales(true);
    78.  
    79. /* set the x/y axis */
    80. //setAxisTitle(QwtPlot::xBottom, " System Uptime [h:m:s]");
    81. //setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw(cpuStat.upTime()));
    82. setAxisTitle(QwtPlot::xBottom, xTitle);
    83. setAxisScale(QwtPlot::xBottom, -HISTORY, 0);
    84. setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    85. setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
    86.  
    87. /*
    88.   set the visual aspect of timestamp axis
    89.   */
    90. QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
    91. const int fmh = QFontMetrics(scaleWidget->font()).height();
    92. scaleWidget->setMinBorderDist(0, fmh / 2);
    93.  
    94. /* y-axis settings */
    95. setAxisTitle(QwtPlot::yLeft, yTitle);
    96. setAxisScale(QwtPlot::yLeft, YMIN, YMAX);
    97. /*set the canvas background color*/
    98. setCanvasBackground(QColor(QColor(Qt::black)));
    99.  
    100. /*
    101.   draw a grid into canvas
    102.   */
    103. QwtPlotGrid *grid = new QwtPlotGrid;
    104. grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
    105. grid->attach(this);
    106.  
    107. /* curve to plot*/
    108. NodeCurve *curve;
    109. QPen pen(Qt::green);//curve color
    110. pen.setWidth(1);
    111. curve = new NodeCurve("Node curve");
    112. //curve->setColor(Qt::green);
    113. curve->setPen(pen);
    114. curve->attach(this);
    115. data.curve = curve;
    116. canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    117.  
    118. /*
    119.   init x-axis scale
    120.   */
    121. for ( int i = 0; i < HISTORY; i++ )
    122. timeData[HISTORY - 1 - i] = i - HISTORY + 1;
    123.  
    124.  
    125. //(void)startTimer(50); // every 50 -millisecond
    126.  
    127. }
    128.  
    129. /*
    130. timer event function: should be called every 50ms ( 20 hz refresh frequency)
    131. */
    132. void NodePlot::timerEvent(QTimerEvent *)
    133. {
    134. mutex.lock();
    135. replot();
    136. mutex.unlock();
    137. }
    138.  
    139.  
    140. void NodePlot::set_params(){
    141. char str[100];
    142. char str2[100];
    143. char str3[100];
    144.  
    145. FILE* file_conf=fopen(".\\Win_QT\\config_canvas.txt","r");
    146.  
    147. while(!feof(file_conf)){
    148. fgets(str,100,file_conf);
    149. sscanf(str,"%s%s",str2,str3);
    150. if(str[0]== '#') continue;
    151. if(strcmp(str2,"HISTORY") == 0){
    152. this->HISTORY=atoi(str3);
    153. }
    154. else if(strcmp(str2,"YMAX") == 0){
    155. this->YMAX=atoi(str3);
    156. }
    157. else if(strcmp(str2,"YMIN") == 0){
    158. this->YMIN=atoi(str3);
    159.  
    160. }
    161. else if(strcmp(str2,"XTITLE") == 0){
    162. strcpy(this->xTitle,str3);
    163. }
    164. else if(strcmp(str2,"YTITLE") == 0){
    165. strcpy(this->yTitle,str3);
    166. }
    167.  
    168. }
    169. fclose(file_conf);
    170.  
    171.  
    172.  
    173. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include"nodeplot.h"
    2. #include<stdio.h>
    3. #include<stdlib.h>
    4. #include <QApplication>
    5. #include <QLabel>
    6. #include <QVBoxLayout>
    7.  
    8.  
    9. int main(int argc, char* argv[]){
    10.  
    11. QApplication a(argc, argv);
    12.  
    13. QWidget vBox;
    14. #if QT_VERSION >= 0x040000
    15. vBox.setWindowTitle("Sensor Plot");
    16. #else
    17. vBox.setCaption("Sensor Plot");
    18. #endif
    19.  
    20. NodePlot plot(&vBox,5000,"localhost",2);
    21.  
    22. QVBoxLayout *layout = new QVBoxLayout(&vBox);
    23. layout->addWidget(&plot);
    24.  
    25.  
    26. #if QT_VERSION < 0x040000
    27. a.setMainWidget(&vBox);
    28. #endif
    29.  
    30. vBox.resize(600,400);
    31. vBox.show();
    32.  
    33.  
    34. return a.exec();
    35. }
    To copy to clipboard, switch view to plain text mode 

    .pro file
    Qt Code:
    1. QT += network
    2.  
    3. HEADERS += nodeplot.h
    4. SOURCES += nodeplot.cpp \
    5. main.cpp
    6. OTHER_FILES += config_canvas.txt
    7.  
    8. INCLUDEPATH += C:\Qt\2009.03\qt\qwt-5.2.0\src
    9. LIBS += C:\Qt\2009.03\qt\qwt-5.2.0\lib\qwt5.dll
    To copy to clipboard, switch view to plain text mode 
    Last edited by agostain; 7th September 2009 at 19:04.

  4. #4
    Join Date
    Dec 2007
    Location
    Modena, Italy
    Posts
    7

    Default Re: port linux app to win (runtime error)

    I had the same probleam yesterday, with both dll and static lib.
    I didn't found a real solution but a simple workaround: recompile qwt disabling the CONFIG += QwtDll in qwtconfig.pri (it is line 78 in 5.2, don't know in 5.1)
    In this manner you won't have the dll and you have to use the static lib, but at least you won't get the runtime error.

Similar Threads

  1. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31

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.