Defined but unused slot throwing up undefined symbol exception
-
We have an application running with Qt 5.12.6 version in x64 platforms and we're porting it to Qt 5.13.2 version to run in an ARM imx8 board. We're compiling the code in an Azure Pipeline and using cross-compilation for generating the ARM binaries.
For both cases the code compiles well, however, there are some defined but unused slots. This gives no problem in the x64 computer, but throws
undefined symbol
exception in the ARM board at runtime.We managed to fix it removing the unused slot declarations, but, is there any way to detect that there are unused slot declarations at compile time? It's interesting for us to know it at compile time, because since we're cross-compiling it's not possible to make a boot-up check in the compile environment.
-
@Aritz said in Defined but unused slot throwing up undefined symbol exception:
undefined symbol exception in the ARM board at runtime
Do you load libraries at runtime?
Usually you get "undefined symbol" linker errors already at build time. -
@Aritz said in Defined but unused slot throwing up undefined symbol exception:
Could this be related?
Yes, if the lib containing the slot is not loaded.
-
@Aritz said in Defined but unused slot throwing up undefined symbol exception:
But there's no code in the plugin using it.
You're aware that moc generates code for every slot so this function is referenced?
-
@Christian-Ehrlicher No, I wasn't aware of that, but it makes sense. Anyway, no .moc files are generated in my build directory. From the docs:
"If you use qmake to create your makefiles, build rules will be included that call the moc when required, so you will not need to use the moc directly."
Shouldn't qmake deal with it directly or maybe do I need an extra flag for it? Basically this is what compiles my project:
mkdir $(Agent.BuildDirectory)/s/my_project/buildDir cd $(Agent.BuildDirectory)/s/my_project/buildDir qmake ../my_project.pro -spec linux-oe-g++ make qmake_all make
-
I don't see what qmake or moc does wrong here. You defined a slot in your class but not implemented it as it seems. The code moc creates references this function (so it can be called via signals/slots and others) so you get an undefined reference.