Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How I link 2 project in creator?
I want link 2 project together but how?
Hi, welcome to devnet.
Assuming project one produces an executable and project two produces a library and you want to keep them in a single workspace then these are the steps:
- Go to project tab and in the dependencies tab of project one select project two. This will assure proper build order.
- Add this to the .pro file of project one:
INCLUDEPATH += path/to/project2/headers/
LIBS += -Lpath/to/lib2/ -lproject2
- (Optional) Add this to .pro file of project one:
PRE_TARGETDEPS += path/to/project2lib
This ensures that if project two is changed it will built before linking to project one.
I try that and ok it works but I get LNK2019 when trying to reference code from other project.
You're gonna have to be more specific than that. This is an unresolved external error, but what symbol doesn't get resolved? Is it from app one, two, Qt or 3rd party lib? Is the symbol a function, an object, an extern?
Did you re-run qmake after making these changes in the .pro file?
Yes it is unresolved for a class in the project 2.
I link by the gui and still it get the link error.
I rerun qmake, clean, etc no difference.
I will try a bare bones tomorrow with 2 basic projects 1 class each only and try to link projects.