Assuming there is C:\somelib\headerfromsomelib.h
. I used to put on my project.pro
the following
INCLUDEPATH += C:\somelib
And on file.cpp
I will put
#include "headerfromsomelib.h"
Then hitting F2
over it will led me to that header file.
In another approach I can, instead, add C:\somelib
to the INCLUDE
environment variable. So its not necessary to add anything to the pro file. And it still builds. I found this approach interesting since it adds flexibility, in a project with multiple developers everyone will be able to have somelib
in a different path.
However hitting F2
on the include line on QtCreator will not led me to the header file anymore. Am I missing something or this is a downside of the this approach?
A more reliable way of using environment variables for library paths is to create environment variables for each library. Eg create an environment variable SOMELIB_PATH
then you can do:
INCLUDEPATH += $$(SOMELIB_PATH)
This can be extended for libraries you need to link to as well:
INCLUDEPATH += $$(SOMELIB_PATH)/include
LIBS += -L$$(SOMELIB_PATH)/lib -lsomelib
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.