Horst Walter
Horst Walter

Reputation: 14081

QtCreator: Avoid redefining LIBS in Qt subdirs project

I have a Qt subdirs project with the following structure:

ExternalQtProject 
QtSubdirProjects
  - GUI
  - WebService

WebService contains LIBS from the external Qt project (.pro file in WebService)

LIBS += -L<path to ExternalQtProject>
LIBS += <some ExternalQtProject .obj files>

GUI uses the web service (.pro file in GUI):

LIBS += -L<path to WebService>
LIBS += <WebService .obj files>

So basically GUI is using one header file from WebService, which in turn uses several header files from ExternalQtProject.

Problem: I get linker issues until I include the LIBS entries from WebService as well in GUI, so GUI ends up with all LIBS from the ExternalQtProject:

LIBS += -L<path to ExternalQtProject> # I want to avoid redefinition of this
LIBS += <some ExternalQtProject .obj files>  # I want to avoid redefinition of this
LIBS += -L<path to WebService>
LIBS += <WebService .obj files>

Since there is a clear dependency (GUI->WebService->ExternalQtProject), is there a way to avoid this redefinition of LIBS for the GUI sub project?

-- Edit 1 --

How to use QMake's subdirs template? helps me to better structure my project, but not yet avoiding the duplication of LIBS

Upvotes: 1

Views: 432

Answers (1)

arb
arb

Reputation: 56

Qmake .pro files can use variables and include other files.

You can e.g. use SOMELIST=foo.obj bar.obj and LIBS += $$SOMELIST when needed.

A SUBDIRS template is used to list different .pro files, each typically responsible for building one binary or one library.

Upvotes: 2

Related Questions