I have a simple QT subdir project with the structure of
TestProject/
TestProject.pro
Subdir1/
Subdir1.pro
sources/
main.cpp
Subdir2/
Subdir2.pro
headers/
mainwindow.h
sources/
mainwindow.cpp
Here are my .pro files TestProject.pro
TEMPLATE = subdirs
SUBDIRS += \
Subdir1 \
Subdir2
Subdir1.pro
SOURCES += \
main.cpp
Subdir2.pro
QT += sql
SOURCES += \
mainwindow.cpp \
HEADERS += \
mainwindow.h \
When I try to run the application I get the following error:
(.text+0x18):-1: error: undefined reference to `main'
I am using the Qt Creator IDE on Ubuntu 12.04. I have spent all morining trying to figure this out, What must I put in the .pro files in order for Qt to be able to build the project?
Thanks in advance
It looks like what you're trying to do is build all your source files into one executable. This is not what the subdirs template is for, it's for creating a single Makefile which builds several different targets (for example two different executables, or an executable and a library).
What you probably want is either to just have a single .pro file with e.g.
SOURCES = Subdir1/mainwindow.cpp Subdir1/main.cpp
Or you can make the subdir pro files into (by convention) .pri files. Then at the top level you would just do:
Try to add your Subdir.pro files into your TestProject.pro file explicitly:
so Qt knows there are subprojects.