Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Problem in Compiling 3MB size class(.cpp) in GUI Application

    General and Desktop
    4
    8
    2201
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zain last edited by

      Hello All,

      In my gui application I have 5 classes with size of 2-3 MB.When I am compiling my application it is seem to be hang and not able to make .o file of that classes.

      I am using Qt4.8.1 and MinGW compiler.

      Am i need to go with advance qt version like QT5.will it do any help to me?
      Please help me how can I compile big size class.

      Thanks in Advance.
      Zain

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        question: why do you have such big class files at all?
        Why not modularize your source? This has the nice side effect that building/linking is much faster in long terms...

        Since it seems that your compiler refuses to work an "upgrade" to Qt5 wont help either.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • M
          MuldeR last edited by

          3 MB of "real" (handwritten) code, i.e. nothing that was auto-generated in some way, in a single file would really be extraordinary. Must be several ten-thousands of lines. So you probably want to refactor that code into multiple files/classes, regardless of the compiler issues. Anyway, Qt's resource compiler (RCC) can easily generate C++ files of that size (or larger), when you "embed" larger files (like images) into your program. The compiler handles those large C++ files just fine in my experience. Might be because they mostly consist of static data though...

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply Reply Quote 0
          • B
            b1gsnak3 last edited by

            2-3 mb of code in 5 classes... that sounds like a bit of work... can't imagine what could be in those classes... try to modularize your classes if it is possible and then if the problem persists... dunno :)

            1 Reply Last reply Reply Quote 0
            • Z
              Zain last edited by

              Thanks Raven for quick reply.

              That class files are containing big xml data by which I need to create xml file at specified path into my system at the time of application load.

              Is it any other way by which I can attach my xml files with application setup package and code to copy that xml file to specified path at the time of application load?

              1 Reply Last reply Reply Quote 0
              • M
                MuldeR last edited by

                Yes.

                Easiest approach, of course, would be to just ship a separate XML files with your program (binary), e.g. inside a ZIP archive. Alternatively wrap all required files into an installer program, e.g. on Windows use NSIS.

                If you really need to embed files into your program (binary), then have a look at:
                http://qt-project.org/doc/qt-4.8/resources.html

                As said above, the Qt RCC will also generate "large" temporary C++ files, which then need to be compiled to object-code files before they can be linked into the program (binary), but in my experience this works fine. Even with files that have a size of several MB's. I do this regularly with my applications.

                NOTE: As Qt's resource system also can store files compressed, a lot of space might be saved with XML data!

                My OpenSource software at: http://muldersoft.com/

                Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                Go visit the coop: http://youtu.be/Jay...

                1 Reply Last reply Reply Quote 0
                • Z
                  Zain last edited by

                  Hey MuldeR Thanks you very much.

                  I have added my XMLs to resource file and it is working fine for me.

                  Thanks to All.

                  1 Reply Last reply Reply Quote 0
                  • B
                    b1gsnak3 last edited by

                    Mark the post as solved thank you :)

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post