INCLUDEPATH how it works ?
If I have a correct path at INCLUDEPATH, why is the reason because I have undefined reference errors for certain h files located at this path ? It is solved if I add the file 'by hand'.
And... I imagine that I could have different versions of files, and I only would have to change the INCLUDEPATH to use one or other, but I think it does not going to work ...
Any explanation ? Thanks
Re: INCLUDEPATH how it works ?
"h" files have nothing to do with unresolved reference errors.
Re: INCLUDEPATH how it works ?
Post your .pro file in the forum.
It seems to be an editing error.
Quote:
Originally Posted by
wysota
"h" files have nothing to do with unresolved reference errors.
Ops. you have right.
------------
Probably you have forgotten some to edit the LIBS variable or to add some dll or obj.
http://doc.trolltech.com/4.7/qmake-v...ence.html#libs
Re: INCLUDEPATH how it works ?
This is the pro file :
Code:
QT += core gui
TEMPLATE = app
CONFIG += qt debug_and_release
TARGET = gui_plu
INCLUDEPATH += ../AnalogWidgets/analogwidgets/analogwidgets \
../AnalogWidgets/analogwidgets/code
HEADERS += form.h \
../AnalogWidgets/analogwidgets/analogwidgets/wallclock.h \
../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ (<<< the line I delete ... )
../AnalogWidgets/analogwidgets/analogwidgets/led.h \
../AnalogWidgets/analogwidgets/plugins/led_plugin.h \
../AnalogWidgets/analogwidgets/plugins/wallclock_plugin.h
SOURCES += form.cpp \
main.cpp \
../AnalogWidgets/analogwidgets/code/wallclock.cpp \
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp \
../AnalogWidgets/analogwidgets/code/led.cpp \
../AnalogWidgets/analogwidgets/plugins/wallclock_plugin.cpp \
../AnalogWidgets/analogwidgets/plugins/led_plugin.cpp
FORMS += \
form.ui
If I delete ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ i have :
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
debug/widgetwithbackground.o: In function `~WidgetWithBackground':
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:32: undefined reference to `vtable for WidgetWithBackground'
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:32: more undefined references to `vtable for WidgetWithBackground' follow
plug1-build-desktop/debug/moc_wallclock.cpp:89: undefined reference to `WidgetWithBackground::qt_metacast(char const*)'
plug1-build-desktop/debug/moc_wallclock.cpp:94: undefined reference to `WidgetWithBackground::qt_metacall(QMetaObject::Ca ll, int, void**)'
debug/moc_wallclock.o:moc_wallclock.cpp:(.rdata+0x0): undefined reference to `WidgetWithBackground::staticMetaObject'
plug1-build-desktop/debug/moc_led.cpp:71: undefined reference to `WidgetWithBackground::qt_metacast(char const*)'
plug1-build-desktop/debug/moc_led.cpp:76: undefined reference to `WidgetWithBackground::qt_metacall(QMetaObject::Ca ll, int, void**)'
debug/moc_led.o:moc_led.cpp:(.rdata+0x0): undefined reference to `WidgetWithBackground::staticMetaObject'
collect2: ld returned 1 exit status
( This file is used by led.h and wallclock.h (#include "widgetwithbackground.h"))
Re: INCLUDEPATH how it works ?
Re: INCLUDEPATH how it works ?
Re: INCLUDEPATH how it works ?
Then rerun qmake under Qt Creator.
Re: INCLUDEPATH how it works ?
Press Right Mouse button -> clean project -> Run qmake. Should working.
Re: INCLUDEPATH how it works ?
Quote:
Originally Posted by
tonnot
I'm using QT Creator ...
main menu > build > run qmake
Re: INCLUDEPATH how it works ?
Qmake does :
Starting: "d:/qt/2010.04/qt/bin/qmake.exe" d:/c++/plug1/plug1.pro -r -spec win32-g++
The process "d:/qt/2010.04/qt/bin/qmake.exe" exited normally.
And nothing more... (My application is not launched)
Then, if I do click on 'run' project all the building process is launched again with the same errors.
Re: INCLUDEPATH how it works ?
Tonnot, please do me a favour. Go through the basic Qt programming tutorial available in Qt documentation. Then get a decent book on C++ programming and read it. We're not here to teach you programming. And you obviously lack the basic knowledge regarding software development.
Re: INCLUDEPATH how it works ?
Yes, because of it I am here (newbie)
Sincerely, I dont know what is happen.
And my main question (the errors I get If I have the INCLUDEPATH ok but not have the .h file added at .pro file) is still without solution ...
Thanks
Re: INCLUDEPATH how it works ?
This is a Qt forum. We're helping with Qt issues. Not with I-don't-know-how-to-program issues. The "newbie" forum is for Qt newbies, not programming newbies. You have to learn by yourself how a compiler works, what are include files, etc.
Re: INCLUDEPATH how it works ?
Excuse me, but I think that I am not making so basic questions.
Of course, I'm learning c++ but I am not asking about how to declare a variable....
And my main question (the errors I get If I have the INCLUDEPATH ok but not have the .h file added at .pro file) is still without solution ...
Thanks
Re: INCLUDEPATH how it works ?
Quote:
Originally Posted by
tonnot
Excuse me, but I think that I am not making so basic questions.
Of course, I'm learning c++ but I am not asking about how to declare a variable....
Ok, I'll treat you as a "programming grown-up" then.
Your problem is the implementation of the offending functions is provided by a precompiler that is ran on header files in search of the Q_OBJECT macro. Classes containing the macro are then scanned for keywords and definitions that later form the meta-object for the class which should then be included in the compilation and linked with the rest of object code. If qmake handles your build process then it pre-scans all files added to the variable containing the list of headers and if Q_OBJECT is spotted in any of them, the file is fed to moc and its result included in the compilation. So to solve your problem you need to make sure that moc preprocesses the files and its result is included in the rest of the compilation.
Re: INCLUDEPATH how it works ?
Uppps Sorry I didn`t see answer from wysota.... :)
Quote:
Originally Posted by
tonnot
but not have the .h file added at .pro file) is still without solution ...
Qmake is kind of tool which can generate Makefiles. When you see into your build folder, there are files like Makafile.Debug, Makafile.Release(propably).
In that files there is a "kind of informction" what will be compiled and how(See ####### Compile). Maybe you should analyze this file, than some problems with compilation will be more clearly, maybe ;)
Re: INCLUDEPATH how it works ?
Quote:
If I delete ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ i have :
Why would you do that if:
Quote:
This file is used by led.h and wallclock.h (#include "widgetwithbackground.h")
and presumably also by widgetwithbackground.cpp.
By removing this file, containing a Q_OBJECT macro, from HEADERS you are telling Qt that it doesn't need to run moc (or anything else) on this file... so it doesn't. This means that the code moc generates on your behalf is not generated, which includes the "vtable" referenced in the error messages from your linker.
The INCLUDEPATH tells the C++ compiler how to find headers other than those in default locations, which it is clearly doing or your code would not compile. It has no bearing on moc.
In short, if you deliberately break it then you get to keep the pieces.
Re: INCLUDEPATH how it works ?
This is the text showed by the QT HELP:
INCLUDEPATH
This variable specifies the #include directories which should be searched when compiling the project. Use ';' or a space as the directory separator.
So, finally ... INCLUDEPATH fails with #include's ?
Thanks for the answers (specially from then last 3 )
Re: INCLUDEPATH how it works ?
No, it doesn't fail with anything. It's just a place where to look for header fiiles. Your problem is not that some header files were not found.
Re: INCLUDEPATH how it works ?
Thanks, WY (and sincerely thank you very much for your patience)
So finally, If you are going to use some custom widgets (using promoting aproach) be carefull to add 'by hand' all the dependant files, isn't it ?
Thanks again