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. #error "The header file 'videostreamer.h' doesn't include <QObject>."
Forum Updated to NodeBB v4.3 + New Features

#error "The header file 'videostreamer.h' doesn't include <QObject>."

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 611 Views 1 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.
  • K Offline
    K Offline
    kirualuka
    wrote on 16 Nov 2021, 05:50 last edited by
    #1

    My QT application works without an error, there is no problem with that.

    But; I need to compile some files to a shared library and I got

    libfoo.so: undefined symbol: _ZTI7QObject
    

    as a compilation error. So, when I look moc_videostreamer.cpp, I saw these lines;

    #error "The header file 'videostreamer.h' doesn't include <QObject>."
    #elif Q_MOC_OUTPUT_REVISION != 67
    #error "This file was generated using the moc from 5.15.2. It"
    #error "cannot be used with the include files from this version of Qt."
    #error "(The moc has changed too much.)"
    

    I included the <QObject> to the header file, my QT application works well, so why getting these error lines?

    J 1 Reply Last reply 16 Nov 2021, 06:16
    0
    • K kirualuka
      16 Nov 2021, 05:50

      My QT application works without an error, there is no problem with that.

      But; I need to compile some files to a shared library and I got

      libfoo.so: undefined symbol: _ZTI7QObject
      

      as a compilation error. So, when I look moc_videostreamer.cpp, I saw these lines;

      #error "The header file 'videostreamer.h' doesn't include <QObject>."
      #elif Q_MOC_OUTPUT_REVISION != 67
      #error "This file was generated using the moc from 5.15.2. It"
      #error "cannot be used with the include files from this version of Qt."
      #error "(The moc has changed too much.)"
      

      I included the <QObject> to the header file, my QT application works well, so why getting these error lines?

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 16 Nov 2021, 06:16 last edited by JKSH
      #2

      @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

      libfoo.so: undefined symbol: _ZTI7QObject
      

      This is a linking error. It probably means your library can't find libQt5Core.so.

      So, when I look moc_videostreamer.cpp, I saw these lines;

      #error "The header file 'videostreamer.h' doesn't include <QObject>."
      #elif Q_MOC_OUTPUT_REVISION != 67
      #error "This file was generated using the moc from 5.15.2. It"
      #error "cannot be used with the include files from this version of Qt."
      #error "(The moc has changed too much.)"
      

      I included the <QObject> to the header file, my QT application works well, so why getting these error lines?

      You did not receive these as error messages during compilation!

      You are looking at the error detection part of the source code. If a problem is detected, then these lines will be printed to your console as error messages.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kirualuka
        wrote on 16 Nov 2021, 08:15 last edited by kirualuka
        #3

        Sorry, I am fairly new to these terms.

        libQt5Core.so
        

        is another shared library, how am I going to link this to my

        libfoo.so
        

        I copied libQt5Core.so in the same directory with libfoo.so and then
        I tried this command:

        g++ -shared -Wl,-soname,libfoo.so -o libQt5Core.so
        

        and then I call it from the python with this line:

        lib = cdll.LoadLibrary('/home/upboard/Project/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Profile/libfoo.so')
        

        But I am keep getting exactly the same error as:

        libfoo.so: undefined symbol: _ZTI7QObject
        
        J W 2 Replies Last reply 16 Nov 2021, 08:41
        0
        • K kirualuka
          16 Nov 2021, 08:15

          Sorry, I am fairly new to these terms.

          libQt5Core.so
          

          is another shared library, how am I going to link this to my

          libfoo.so
          

          I copied libQt5Core.so in the same directory with libfoo.so and then
          I tried this command:

          g++ -shared -Wl,-soname,libfoo.so -o libQt5Core.so
          

          and then I call it from the python with this line:

          lib = cdll.LoadLibrary('/home/upboard/Project/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Profile/libfoo.so')
          

          But I am keep getting exactly the same error as:

          libfoo.so: undefined symbol: _ZTI7QObject
          
          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 16 Nov 2021, 08:41 last edited by
          #4

          @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

          and then I call it from the python with this line:

          lib = cdll.LoadLibrary('/home/upboard/Project/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Profile/libfoo.so')
          

          But I am keep getting exactly the same error as:

          libfoo.so: undefined symbol: _ZTI7QObject
          

          First, run ldd libfoo.so to see which libraries it cannot find. I suspect there might be more than 1.

          libQt5Core.so
          

          is another shared library,

          Yes, that is the core Qt library which contains QObject.

          how am I going to link this to my

          libfoo.so
          

          You must first ensure that libfoo.so can find all of the other libraries that it depends on. That means ldd must not say that anything is "not found"

          I copied libQt5Core.so in the same directory with libfoo.so

          That won't work on Linux, because libfoo.so won't search its own directory by default. Instead, you must set libfoo.so's RPATH or RUNPATH to search the dirrectory that contains the Qt libraries.

          http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          K 1 Reply Last reply 16 Nov 2021, 09:19
          2
          • J JKSH
            16 Nov 2021, 08:41

            @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

            and then I call it from the python with this line:

            lib = cdll.LoadLibrary('/home/upboard/Project/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Profile/libfoo.so')
            

            But I am keep getting exactly the same error as:

            libfoo.so: undefined symbol: _ZTI7QObject
            

            First, run ldd libfoo.so to see which libraries it cannot find. I suspect there might be more than 1.

            libQt5Core.so
            

            is another shared library,

            Yes, that is the core Qt library which contains QObject.

            how am I going to link this to my

            libfoo.so
            

            You must first ensure that libfoo.so can find all of the other libraries that it depends on. That means ldd must not say that anything is "not found"

            I copied libQt5Core.so in the same directory with libfoo.so

            That won't work on Linux, because libfoo.so won't search its own directory by default. Instead, you must set libfoo.so's RPATH or RUNPATH to search the dirrectory that contains the Qt libraries.

            http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.

            K Offline
            K Offline
            kirualuka
            wrote on 16 Nov 2021, 09:19 last edited by kirualuka
            #5

            You must first ensure that libfoo.so can find all of the other libraries that it depends on. That means ldd must not say that anything is "not found"

            I copied libQt5Core.so in the same directory with libfoo.so

            ldd libfoo.so results are:
            
            ldd libfoo.so
            	linux-vdso.so.1 (0x00007ffe0e3c0000)
            	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fedc79dd000)
            	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fedc763f000)
            	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fedc7427000)
            	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fedc7036000)
            	/lib64/ld-linux-x86-64.so.2 (0x00007fedc7f7d000)
            

            There is not sth. like "not found" Does that mean libfoo.so can find all of the other libraries that it depends on?
            So the next step is setting the RUNPATH?

            That won't work on Linux, because libfoo.so won't search its own directory by default. Instead, you must set libfoo.so's RPATH or RUNPATH to search the dirrectory that contains the Qt libraries.

            http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.

            In the referred link, it is explained to set the RPATH for a QT exe files. I don't actually have an exe file and I couldn't get how to set libfoo.so's RPATH for searching the dirrectory that contains the Qt libraries. How to link these two with setting rpath..

            J 1 Reply Last reply 16 Nov 2021, 23:09
            0
            • K kirualuka
              16 Nov 2021, 09:19

              You must first ensure that libfoo.so can find all of the other libraries that it depends on. That means ldd must not say that anything is "not found"

              I copied libQt5Core.so in the same directory with libfoo.so

              ldd libfoo.so results are:
              
              ldd libfoo.so
              	linux-vdso.so.1 (0x00007ffe0e3c0000)
              	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fedc79dd000)
              	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fedc763f000)
              	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fedc7427000)
              	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fedc7036000)
              	/lib64/ld-linux-x86-64.so.2 (0x00007fedc7f7d000)
              

              There is not sth. like "not found" Does that mean libfoo.so can find all of the other libraries that it depends on?
              So the next step is setting the RUNPATH?

              That won't work on Linux, because libfoo.so won't search its own directory by default. Instead, you must set libfoo.so's RPATH or RUNPATH to search the dirrectory that contains the Qt libraries.

              http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.

              In the referred link, it is explained to set the RPATH for a QT exe files. I don't actually have an exe file and I couldn't get how to set libfoo.so's RPATH for searching the dirrectory that contains the Qt libraries. How to link these two with setting rpath..

              J Offline
              J Offline
              JKSH
              Moderators
              wrote on 16 Nov 2021, 23:09 last edited by
              #6

              @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

              ldd libfoo.so results are:
              
              ldd libfoo.so
              	linux-vdso.so.1 (0x00007ffe0e3c0000)
              	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fedc79dd000)
              	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fedc763f000)
              	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fedc7427000)
              	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fedc7036000)
              	/lib64/ld-linux-x86-64.so.2 (0x00007fedc7f7d000)
              

              That's interesting. I presume that libfoo.so uses Qt? If so, then it is supposed to have a dependency on libQt5Core.so, at the very least.

              How did you build libfoo.so?

              In the referred link, it is explained to set the RPATH for a QT exe files. I don't actually have an exe file and I couldn't get how to set libfoo.so's RPATH for searching the dirrectory that contains the Qt libraries. How to link these two with setting rpath..

              Both executable files and shared object (.so) files can have RPATH.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • K kirualuka
                16 Nov 2021, 08:15

                Sorry, I am fairly new to these terms.

                libQt5Core.so
                

                is another shared library, how am I going to link this to my

                libfoo.so
                

                I copied libQt5Core.so in the same directory with libfoo.so and then
                I tried this command:

                g++ -shared -Wl,-soname,libfoo.so -o libQt5Core.so
                

                and then I call it from the python with this line:

                lib = cdll.LoadLibrary('/home/upboard/Project/build-Project-Desktop_Qt_5_15_2_GCC_64bit-Profile/libfoo.so')
                

                But I am keep getting exactly the same error as:

                libfoo.so: undefined symbol: _ZTI7QObject
                
                W Offline
                W Offline
                wrosecrans
                wrote on 19 Nov 2021, 18:31 last edited by
                #7

                @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

                g++ -shared -Wl,-soname,libfoo.so -o libQt5Core.so

                That looks very wrong. "-o" specifies the name of the output file. So you are saying to output a new file called libQt5Core.so, not to link to an existing libQt5Core. Also, you don't seem to specify any inputs, so I am assuming that's not really a command you ran, just a sort of impressionistic hint of it, which is 100% not useful for getting help with debugging.

                @JKSH said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

                That's interesting. I presume that libfoo.so uses Qt? If so, then it is supposed to have a dependency on libQt5Core.so, at the very least.
                How did you build libfoo.so?

                If libfoo.so isn't linked to libQt5Core (and every indication is that it wasn't) then the dynamic linker won't have any reason to specifically try to look for it, thus no message about failing to find it.

                Anyhow, tldr: solve linker errors about missing symbols by linking the relevant library, not by hacking on includes in unrelated header files.

                J 1 Reply Last reply 19 Nov 2021, 22:11
                1
                • W wrosecrans
                  19 Nov 2021, 18:31

                  @kirualuka said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

                  g++ -shared -Wl,-soname,libfoo.so -o libQt5Core.so

                  That looks very wrong. "-o" specifies the name of the output file. So you are saying to output a new file called libQt5Core.so, not to link to an existing libQt5Core. Also, you don't seem to specify any inputs, so I am assuming that's not really a command you ran, just a sort of impressionistic hint of it, which is 100% not useful for getting help with debugging.

                  @JKSH said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

                  That's interesting. I presume that libfoo.so uses Qt? If so, then it is supposed to have a dependency on libQt5Core.so, at the very least.
                  How did you build libfoo.so?

                  If libfoo.so isn't linked to libQt5Core (and every indication is that it wasn't) then the dynamic linker won't have any reason to specifically try to look for it, thus no message about failing to find it.

                  Anyhow, tldr: solve linker errors about missing symbols by linking the relevant library, not by hacking on includes in unrelated header files.

                  J Offline
                  J Offline
                  JKSH
                  Moderators
                  wrote on 19 Nov 2021, 22:11 last edited by
                  #8

                  @wrosecrans said in #error "The header file 'videostreamer.h' doesn't include <QObject>.":

                  tldr: solve linker errors about missing symbols by linking the relevant library

                  +1

                  And projects that use Qt should also use a build system (e.g. qmake or CMake), not call g++ directly

                  not by hacking on includes in unrelated header files.

                  To be fair, OP didn't seem to hack any headers. They only looked at a moc-generated header and misinterpreted it.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0

                  1/8

                  16 Nov 2021, 05:50

                  • Login

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