Undefined reference - again - discussion
-
@AnneRanch said in Undefined reference - again - discussion:
I change the TEMPLATE in .pro to app, BUT fails when the TEMPLATE is set to library.
this might be the crux of the problem, did you do that previously to the error appearing as well ?
The build system usually doesn't rebuild object files on its own, if there are no changes in the source files. But changing from standalone app to library does require different object files.
this is for example one of the reasons, why shadow build folders in QtCreator have the QtVersion/Compiler in its name. To not mix obj files created.
-
@J-Hilk I am using changing the TEMPLATE as debugging tool.
In my case just to make sure the code works / runs independent of library usage.
I actually have two copies of the "problem
" source code - one in subdirs project and one as an independent project.Mainly because when I change the template to app , I cannot "run" the problem code , the main subdirs project does not like "two" main apps.
BTW
I think the problem is in "mixing " include and actual link to the .so code - I am going to verify all of the next.
-
@AnneRanch OK, here is complier / linker output AFTER the TEMPLATE = lib
09:31:01: Running steps for project terminal...
09:31:01: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug
Project MESSAGE: RESTOREd ALL resouces - DEBUG commneted out options resouces - same issue
Project MESSAGE: Changed back to TEMPLATE = lib
/mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro:36: message(message) requires one argument.
Project MESSAGE:
09:31:01: The process "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" exited normally.09:31:01: Starting: "/usr/bin/make" -f /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/Makefile qmake_all
make: Nothing to be done for 'qmake_all'.
09:31:01: The process "/usr/bin/make" exited normally.09:31:01: Starting: "/usr/bin/make" -j4
rm -f libterminal.so.1.0.0 libterminal.so libterminal.so.1 libterminal.so.1.0
clang++ -ccc-gcc-name g++ -Wl,-rpath,/home/nov25-1/Qt/5.15.2/gcc_64/lib -shared -Wl,-soname,libterminal.so.1 -o libterminal.so.1.0.0 main.o settingsdialog.o console.o terminal_ORIGINAL_mainwindow.o qrc_terminal.o moc_settingsdialog.o moc_console.o moc_terminal_ORIGINAL_mainwindow.o /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so/home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Gui.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5SerialPort.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread
ln -s libterminal.so.1.0.0 libterminal.so
ln -s libterminal.so.1.0.0 libterminal.so.1
ln -s libterminal.so.1.0.0 libterminal.so.1.0
09:31:03: The process "/usr/bin/make" exited normally.
09:31:03: Elapsed time: 00:02.1.Does THIS output help me to ADD correct #include header to the "parent " class ?
2.Does THIS output help me to ADD correct "library" to the "parent " class ?
Using "Add library" option - internal or external or ...
-
@AnneRanch
After
changing the #include to#include < header file >
adding library using "external " with full path
I still get same , agree this is a linker, error pointing to here:
// TEST_SUBPROJECT text = " TEMPORARY WINDOW TITLE CHANGED index 40 ..."; TEST_PROJECT_MainWindow *pTEST_INDEX = new TEST_PROJECT_MainWindow(); pTEST_INDEX->setWindowTitle(text); add_mdi_subwindow (pTEST_INDEX); // debug terminal issue This code fails but there is no compiler error indicated **terminal_ORIGINAL_MainWindow *pTERMINAL = new terminal_ORIGINAL_MainWindow(); add_mdi_subwindow (pTERMINAL);** This code fails but there is no compiler indicated
-
@AnneRanch said in Undefined reference - again - discussion:
This code fails but there is no compiler error indicated
That is because it is a linker error. You told the compiler that there is a
terminal_ORIGINAL_MainWindow
class in another file, but you did not link withterminal_ORIGINAL_MainWindow.o
, which you need to do as it has the class code, so the linker could not succeed.If you had not
#include
d theterminal_ORIGINAL_MainWindow.h
file THAT would have given a compilation error on thenew terminal_ORIGINAL_MainWindow()
line. But including that allows it to compile, and says theterminal_ORIGINAL_MainWindow.o
object file will be provided at link time. But, for whatever reason, it is not when you get your error.That is what the
Undefined reference
error message from linker (ld
) indicates each time. -
This post is deleted!
-
UPDATE
I have given up trying to physically find the "linker" problem.
I am trying a DIFFERENT way to resolve this AND could use some help.I now have TWO "subdirs" projects - my main one , the one which refuses to work , and working "helper project".
The "helper project" works as expected - here is the result:
 main window" with
A_Mar7_MAR17.pro as child.I do realize this approach is convoluted, but my main goal is is to link "TEST_MAIN_SUBPROJECT " with "terminal" irregardless how many parent - child levels it takes.
THANKS
-
@AnneRanch UPDATE
Question
what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?09:12:11: Running steps for project TEST_MAIN_SUBPROJECT...
09:12:11: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_APR/A_APR6_MAR7_MAR19_CLEAN/A_BT_LIBRARY/CCC_SOURCE/TEST_MAIN_SUBPROJECT_PROJECT/TEST_MAIN_SUBPROJECT/TEST_MAIN_SUBPROJECT.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug CONFIG+=force_debug_info CONFIG+=separate_debug_info
Project MESSAGE:
Project MESSAGE: run TEST_MAIN_SUBPROJECT.pro
Project MESSAGE:it is LAST .pro in the project
-
@AnneRanch said in Undefined reference - again - discussion:
what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?
when your project creates multiple executables that could potentially be executed. You can specify inside the project tab under "run settings" which executable is supposed to be run.
-
@JonB Unfortunately 'run setting" does not let select .pro but sudirs project executable.
That does not help to bypass the terminal problem.
If I select modify and select "mdi" it actually runs the "mdi" BEFORE the modification.
The editor shows errors , it should, and it should not run. -
J JonB referenced this topic on
-
@JonB OK, back to terminology...
I use "Add library" to add it to the subproject / object who needs it...
I let Qt to select "internal" library ....by project name - AKA "terminal"
From there it is Qt who actually adds stuff - mostly to .pro file.I have to add required headers...
editor and compiler passes the headers as validThen I usually run "Clear" and "Rebuild".
That is it...I do not see the references to library.o AND library.so until the complier / linker is done.
The linker error is actually very last few lies of the "Rebuild" process.