문제

I have a project in Qt Creator which has several shared library projects and the main project which also contains the main function. What I want is to add a new project which shouldn't be a shared library but just a project with some header files where I keep definitions and error codes. What I wish is to be able to add the path of this project to other projects INCLUDEPATH in order to use those files in other projects.

To do so I created an empty project which .pro file looks like this:

HEADERS += \
    myHeader.h

but when I build the whole project it complains that it doesn't find the main in this project with only one header.

Is it possible in QtCreator to achieve this?

도움이 되었습니까?

해결책

Create a .pri file which has your INCLUDEPATH, etc; and then refer to it in your other projects' .pro files:

# Common.pri
INCLUDEPATH += ../myPath
INCLUDE += myHeader.h

# OtherProject.pro
!include( ./Common.pri ) {
    error( Could not find the Common.pri file. )
}

INCLUDEPATH += ../myOtherPath

Remember to use the += operator in your .pro files otherwise they will overwrite the .pri file variables.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top