Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to increase object file section capacity
Forum Updated to NodeBB v4.3 + New Features

How to increase object file section capacity

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 8 Posters 2.1k Views 4 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #11

    @JonB I just encountered this error, as evinced by this message:

    mocs_compilation.cpp.obj: too many sections (32884)
    C:\Users\MICHAE~1.ZIM\AppData\Local\Temp\cclcUK6a.s: Assembler messages:
    C:\Users\MICHAE~1.ZIM\AppData\Local\Temp\cclcUK6a.s: Fatal error: can't write 11 bytes to section .text of appNgaIcdFw/CMakeFiles/appNgaIcdFw.dir/appNgaIcdFw_autogen/mocs_compilation.cpp.obj: 'file too big'
    

    Your suggestion fixes it, but the result is a huge executable (like 3X the size of a standalone static image). So, something is just not right here. Oh - I only get this build error on Windows - the same project does just fine on Ubuntu.

    I'm wondering whether there's some more cmake magic that might help ameliorate this...

    I 1 Reply Last reply
    0
    • Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by
      #12

      I encountered a similar problem in a different project. However, in my scenario it wasn't large portions of binary data but just a lot of templated boost code.
      When using MinGW, -mbig-obj wasn't enough. I also had to go for an O3 optimization level.
      As the same project also needed to compile with MSVC I used CMake generator expressions: https://github.com/Tectu/malloy/blob/9b7145a8834d387ccc25f51f8345fb31f5e17538/lib/malloy/target_setup.cmake#L8

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      mzimmersM 1 Reply Last reply
      0
      • Joel BodenmannJ Joel Bodenmann

        I encountered a similar problem in a different project. However, in my scenario it wasn't large portions of binary data but just a lot of templated boost code.
        When using MinGW, -mbig-obj wasn't enough. I also had to go for an O3 optimization level.
        As the same project also needed to compile with MSVC I used CMake generator expressions: https://github.com/Tectu/malloy/blob/9b7145a8834d387ccc25f51f8345fb31f5e17538/lib/malloy/target_setup.cmake#L8

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #13

        @Joel-Bodenmann I have absolutely no idea why my image is getting so large. It's not a huge code base at all, and I'm not importing anything large. I wonder if using a different toolchain might help...?

        1 Reply Last reply
        0
        • Joel BodenmannJ Offline
          Joel BodenmannJ Offline
          Joel Bodenmann
          wrote on last edited by
          #14

          If you're importing an image, why not just use Qt's RCC?

          Industrial process automation software: https://simulton.com
          Embedded Graphics & GUI library: https://ugfx.io

          mzimmersM 1 Reply Last reply
          0
          • Joel BodenmannJ Joel Bodenmann

            If you're importing an image, why not just use Qt's RCC?

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #15

            @Joel-Bodenmann sorry - I used the term "image" to refer to the built executable. (That's what we used to call them back in the old days.) I'm not importing anything that should be contributing to this issue.

            1 Reply Last reply
            0
            • mzimmersM mzimmers

              @JonB I just encountered this error, as evinced by this message:

              mocs_compilation.cpp.obj: too many sections (32884)
              C:\Users\MICHAE~1.ZIM\AppData\Local\Temp\cclcUK6a.s: Assembler messages:
              C:\Users\MICHAE~1.ZIM\AppData\Local\Temp\cclcUK6a.s: Fatal error: can't write 11 bytes to section .text of appNgaIcdFw/CMakeFiles/appNgaIcdFw.dir/appNgaIcdFw_autogen/mocs_compilation.cpp.obj: 'file too big'
              

              Your suggestion fixes it, but the result is a huge executable (like 3X the size of a standalone static image). So, something is just not right here. Oh - I only get this build error on Windows - the same project does just fine on Ubuntu.

              I'm wondering whether there's some more cmake magic that might help ameliorate this...

              I Offline
              I Offline
              IgKh
              wrote on last edited by
              #16

              @mzimmers said in How to increase object file section capacity:

              mocs_compilation.cpp.obj

              Looks like you got bit by AUTOMOC merging all meta objects into a single cpp file. Static QMetaObject are full of strings, and you probably have a lot of QObjects. See https://gitlab.kitware.com/cmake/cmake/-/issues/22161

              mzimmersM 1 Reply Last reply
              1
              • I IgKh

                @mzimmers said in How to increase object file section capacity:

                mocs_compilation.cpp.obj

                Looks like you got bit by AUTOMOC merging all meta objects into a single cpp file. Static QMetaObject are full of strings, and you probably have a lot of QObjects. See https://gitlab.kitware.com/cmake/cmake/-/issues/22161

                mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #17

                @IgKh Ouch. I'd guess I have on the order of ~100 subclasses of QObject. Hard to believe that would break the build, but I guess it does.

                So, regarding the solution you posted, is this something that can be done incrementally? In other words, if I just add the MOC include in a few files, will that show a minor improvement, or do I need to do it to everything in order to get results?

                Thanks...

                I 1 Reply Last reply
                0
                • mzimmersM mzimmers

                  @IgKh Ouch. I'd guess I have on the order of ~100 subclasses of QObject. Hard to believe that would break the build, but I guess it does.

                  So, regarding the solution you posted, is this something that can be done incrementally? In other words, if I just add the MOC include in a few files, will that show a minor improvement, or do I need to do it to everything in order to get results?

                  Thanks...

                  I Offline
                  I Offline
                  IgKh
                  wrote on last edited by
                  #18

                  @mzimmers yes, you can do this incrementaly

                  1 Reply Last reply
                  1
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #19

                    You should always include the moc_foo.cpp in your source file instead relying on automoc's foo_compilation.cpp magic. Then you will also get more diagnostic output (at least for gcc) since the compiler sees the whole class in one compilation unit.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    mzimmersM 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      You should always include the moc_foo.cpp in your source file instead relying on automoc's foo_compilation.cpp magic. Then you will also get more diagnostic output (at least for gcc) since the compiler sees the whole class in one compilation unit.

                      mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #20

                      @Christian-Ehrlicher OK, and is this the preferred syntax (taken from the solution @IgKh provided)?

                      // myobject.cpp
                      #include "myobject.h"
                      
                      MyObject::MyObject(QObject *parent)
                          : QObject(parent)
                      {
                      }
                      
                      #include <moc_myobject.cpp>
                      
                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • mzimmersM mzimmers

                        @Christian-Ehrlicher OK, and is this the preferred syntax (taken from the solution @IgKh provided)?

                        // myobject.cpp
                        #include "myobject.h"
                        
                        MyObject::MyObject(QObject *parent)
                            : QObject(parent)
                        {
                        }
                        
                        #include <moc_myobject.cpp>
                        
                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #21

                        @mzimmers said in How to increase object file section capacity:

                        and is this the preferred syntax

                        Yes

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved