Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
"Undefined symbols in architecture" Compile Error after Refactoring Directories
First of all, I've already checked out the other forum threads and stackoverflows on "Undefined symbols in architecture" errors but I felt that they didn't match my error.
I recently started using Qt for a school project. Along the way I accumulated a bunch of #define macros that I grouped into several headers (.h files). But as the number of constants and macros grew and the number of header files grew, the header files began to cloud the workspace (i.e. the source code).
So following some examples, I dividing the directory into two folders src and convenience.
But when building and running, I get this error:
The main.cpp file is under the src directory.
I'm using Qt Creator 4.6.0 on a MacOS High Sierra v10.13.4.
Any help would be appreciated.
@ResistorInTheDark How do your pro files look? Did you rerun qmake and rebuild?
In C++ you should not use #define for constants that much :-)
Use const instead and put your constants in name spaces.
ResistorInTheDark last edited by ResistorInTheDark
QtCombinedApp .pro file:
TEMPLATE = subdirs SUBDIRS = src convenience CONFIG += ordered
convenience .pro file:
SOURCES += \ conveniencefile.cpp HEADERS += \ appdisplay.h \ appfont.h \ (and several other files)
src .pro file:
QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = QtCombinedApp TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ mainwindow.cpp \ (other .cpp source files) HEADERS += \ mainwindow.h \ (other .h source files) RESOURCES += \ images.qrc
I also tried running qmake, no errors, I believe. I also tried deleting previous builds and rebuilding but that didn't work and generated the linker error.
Actually, I just got it to work.
Apparently I had to set
Template = liband
Target = QtCombinedApp.
I took your other advice and switched over to
Thanks for your help and quick reply!
Pablo J. Rogina last edited by
@ResistorInTheDark if your issue is solved, please mark your post as such. Thanks.
Done, thanks for the tip. :-)