Results 1 to 6 of 6

Thread: reference table and Qt compilation

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Question reference table and Qt compilation

    I have a program that needs to read in a reference table during runtime. The table is basically two 1-dimensional arrays of doubles (QList<double>). Currently I do it by referring to a function which is nothing more than the statements for arrays:

    Qt Code:
    1. QList<double> array1, array2;
    2. void readRef()
    3. {
    4. array1[0]=2.45; array2[0]=5.17;
    5. array1[1]=3.78; array2[1]=3.12;
    6. .....
    7. array1[1700]=4.67; array2[1700]=0.12;
    8. }
    To copy to clipboard, switch view to plain text mode 

    This method should work, but I run into weird problems. For example it compiles on 32 Debian to give a 1 MB executable which runs fine. When I compile the same program on 64 bit Scientific Linux (RedHat) it takes a long time to compile and the executable is 70 MB and it won't run (I get a weird message that an X-something is not found). I'm pretty sure that my functions that contain all the array definitions cause this because without this table the program runs fine on both systems. Does anyone know what is happening. Is there something Qt-specific about compiling programs that contain functions with only array statements?
    Thank you!

  2. #2
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reference table and Qt compilation

    I got the program to work. There was a problem with what i included (#INCLUDE). However the rest of the problem is still there. My reference table is only 50 kb of text. When I compile the program so that it becomes part of my program (see above) the size of my executable jumps from 1 mb to 70 mb! Why doesn't it go from 1 mb to 1.05 mb? What am I missing? Maybe I should use other options to compile. Right now I simply do:

    qmake -project
    qmake
    make

    Thanks!

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: reference table and Qt compilation

    Where do you set the sizes of the two QLists to 1700? I sure hope you do, because QList:perator[]() won't "grow" the list if the array index is out of bounds.

    Possibly the size difference is partly due to the size of a double on the two systems. Have you added something like "qDebug() << sizeof( double );" to see what it actually is?

    But I am guessing that the change in the size of the program has nothing to do with your data table, but more to do with the operating system and how it links the executable. On the 64-bit system, it may be statically linking to libraries that are dynamic on your Debian system, for example.

  4. The following user says thank you to d_stranz for this useful post:

    timmu (7th September 2012)

  5. #4
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reference table and Qt compilation

    I set the size of the array like this.

    Qt Code:
    1. QList<double> array1, array2;
    2.  
    3. for (i=0; i<1701; i++) {array1.append(0.0); array2.append(0.0);}
    4.  
    5. void readRef()
    6. {
    7. array1[0]=2.45; array2[0]=5.17;
    8. array1[1]=3.78; array2[1]=3.12;
    9. .....
    10. array1[1700]=4.67; array2[1700]=0.12;
    11. }
    To copy to clipboard, switch view to plain text mode 

    If the size of double differs between the two systems, then there is nothing I can do about that, right? Would you recommend using "const" with array definition somehow?

    I think it makes sense that the two systems do the linking differently. But how would I change the way the linking is done?

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: reference table and Qt compilation

    Quote Originally Posted by timmu View Post
    When I compile the program so that it becomes part of my program (see above) the size of my executable jumps from 1 mb to 70 mb! Why doesn't it go from 1 mb to 1.05 mb?
    Are you compiling in release or debug mode?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: reference table and Qt compilation

    for (i=0; i<1701; i++) {array1.append(0.0); array2.append(0.0);}
    Do this first for efficiency:

    Qt Code:
    1. array1.reserve( 1701 );
    2. array2.reserve( 1701 );
    3.  
    4. for (i=0; i<1701; i++) {array1.append(0.0); array2.append(0.0);}
    To copy to clipboard, switch view to plain text mode 

    Without it, your arrays will be repeatedly reallocated as you add more to them.

    And as wysota asks, compiling in debug vs. release mode could cause the difference in program size.

Similar Threads

  1. Replies: 1
    Last Post: 8th June 2011, 14:13
  2. Validator for the table widget item in table
    By mukunda in forum Qt Programming
    Replies: 4
    Last Post: 6th June 2011, 23:07
  3. QT4.4.3 Compilation : undefined symbol reference QIconvCodec::QIconvCodec()
    By anoop7181 in forum Installation and Deployment
    Replies: 0
    Last Post: 28th March 2011, 14:21
  4. Replies: 3
    Last Post: 3rd December 2010, 15:21
  5. Replies: 9
    Last Post: 21st June 2007, 10:27

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.