PDA

View Full Version : How to setup paths in a pro file



robsofmar
12th February 2013, 16:20
Hi Guys,

How do I do the following;

This is a simplification of the map setup I have so far


projects
project_1
file_a.cpp
file_a.h
file_b.cpp
file_b.h

and now I want to do the following


projects
project_1
file_a.cpp
file_a.h
shared
file_b.cpp
file_b.h
project_2
file_c.cpp
file_c.h

So I want to share file_b over two projects. Everytime I open project 1 or 2 I get to file_b and if I make changes in project 1, file_b is updated so project 2 can also make use of the new functionality.

How do I proceed to make this possible?

Many thanks in advance!
Rob

Santosh Reddy
12th February 2013, 16:46
You could simply add the file_b.* to both the projects i.e to project_1 and project_2.
or
If project_1 and project_2 are related, i.e. you generally build/rebuild them togeather then you make them as sub-directory projects with a top level project

ChrisW67
12th February 2013, 23:31
One way to arrange it:


projects
project_1
project_1.pro // see below
file_a.cpp
file_a.h
shared
shared.pri // see below
file_b.cpp
file_b.h
project_2
project_2.pro // see below
file_c.cpp
file_c.h


In the project files:

TEMPLATE = app
...
include(../shared/shared.pri)

and in shared.pri

INCLUDEPATH += $${PWD}
DEPENDPATH += $${PWD}
HEADERS += $${PWD}/file_b.h
SOURCES += $${PWD}/file_b.cpp

Then when you add or remove files from shared the other projects automatically get them. file_a.cpp can directly #include "file_b.h" without worrying about relative paths etc.


Alternatively, you could make "shared" a static library project and use:

LIBS += -L../shared -lshared

in projects a and b.

Lots of variations on the theme.

robsofmar
13th February 2013, 12:08
Thanks to your input I got it working the way I want it now. Thx a lot!