Moc not generating functions
-
@Redman Type all. But that's not the problem here.
@Christian-Ehrlicher So how can I tell moc to add the functions?
-
@Christian-Ehrlicher So how can I tell moc to add the functions?
@Redman said in Moc not generating functions:
@Christian-Ehrlicher So how can I tell moc to add the functions?
As I already said there is no problem with moc but you don't compile configuration.cpp anywhere.
-
@Redman said in Moc not generating functions:
@Christian-Ehrlicher So how can I tell moc to add the functions?
As I already said there is no problem with moc but you don't compile configuration.cpp anywhere.
-
@Christian-Ehrlicher
The service.exe, which is configured in app.pro, is built correct. The exe can only be a result of a successful compilation. So I'd assume configuration.cpp is compiled@Redman said in Moc not generating functions:
So I'd assume configuration.cpp is compiled
Don't assume, check.
You did not show any pro file where you compile configuration.cpp so my answer still stands... -
@Redman said in Moc not generating functions:
So I'd assume configuration.cpp is compiled
Don't assume, check.
You did not show any pro file where you compile configuration.cpp so my answer still stands...I think this should answer your question.
To elaborate further:
project.proSUBDIRS = \ client \ logger \ service # where to find the sub projects - give the folders client.subdir = src/client logger.subdir = src/logger service.subdir = src/serviceTEMPLATE = subdirs SUBDIRS = \ app \ test \ # where to find the sub projects - give the folders app.subdir = app test.subdir = test test.depends = appSo far all I had to do was include the sources and headers in the pro files and the projects simply compiled. Please enlighten me if I'm missing something crucial.
update:
Afterdumpbin.exe Configuration.obj /disasm
Even though we see the function is present in the obj file I still get following error
error: LNK2019: unresolved external symbol ""public: __cdecl Configuration::Configuration(class QObject *)" (??0Configuration@@QEAA@PEAVQObject@@@Z)" in function ""private: static void __cdecl TestConfig::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@TestConfig@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)".What makes me wonder is the second part of the error message. But I guess thats just how Qt invokes all function calls for classes that inherit from QObject.
-
I think this should answer your question.
To elaborate further:
project.proSUBDIRS = \ client \ logger \ service # where to find the sub projects - give the folders client.subdir = src/client logger.subdir = src/logger service.subdir = src/serviceTEMPLATE = subdirs SUBDIRS = \ app \ test \ # where to find the sub projects - give the folders app.subdir = app test.subdir = test test.depends = appSo far all I had to do was include the sources and headers in the pro files and the projects simply compiled. Please enlighten me if I'm missing something crucial.
update:
Afterdumpbin.exe Configuration.obj /disasm
Even though we see the function is present in the obj file I still get following error
error: LNK2019: unresolved external symbol ""public: __cdecl Configuration::Configuration(class QObject *)" (??0Configuration@@QEAA@PEAVQObject@@@Z)" in function ""private: static void __cdecl TestConfig::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@TestConfig@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)".What makes me wonder is the second part of the error message. But I guess thats just how Qt invokes all function calls for classes that inherit from QObject.
Provide a minimal, compilable example. Don't use global globs to add files so we can see where exactly configuration.cpp is compiled into since you still (after 5 posts from me) failed to do so.
-
Provide a minimal, compilable example. Don't use global globs to add files so we can see where exactly configuration.cpp is compiled into since you still (after 5 posts from me) failed to do so.
-
As I said - there is no library where you link your configuration.cpp - you only compile it directly to your app.
So either also directly link it to your testcase or create a library and link the library to your app and your test. -
@Christian-Ehrlicher
#ifndef CONFIGURATION_H is present. I missed it while copying.My project structure:

QT += testlib QT -= gui TARGET = TestService CONFIG += qt console warn_on depend_includepath testcase CONFIG -= app_bundle CONFIG -= debug_and_release TEMPLATE = app SOURCES += \ $$files("$$PWD/src/*.cpp", true)@Redman said in Moc not generating functions:
SOURCES +=
$$files("$$PWD/src/*.cpp", true)If you insist on using this any further, you need to adjust your paths. To add configuration.cpp to your test.pro the path needs to be $$PWD/../app/src/*.cpp because $$PWD is service/test, but your sources are locate in service/app/src.
$$PWDstands for "print working directory" and thus your working directory for app.pro and test.pro is different. -
R Redman has marked this topic as solved on

