#error "The header file 'videostreamer.h' doesn't include <QObject>."
-
wrote on 16 Nov 2021, 05:50 last edited by
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?
-
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?
@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.
-
wrote on 16 Nov 2021, 08:15 last edited by kirualuka
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
-
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
@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
orRUNPATH
to search the dirrectory that contains the Qt libraries.http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.
-
@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
orRUNPATH
to search the dirrectory that contains the Qt libraries.http://www.tripleboot.org/?p=138#Linux for instructions on how to set these.
wrote on 16 Nov 2021, 09:19 last edited by kirualukaYou 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
orRUNPATH
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..
-
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
orRUNPATH
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..
@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.
-
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
wrote on 19 Nov 2021, 18:31 last edited by@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.
-
@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.
@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.
1/8