c++ - Qmake Project File -
i have class file (header , cpp) made, want use in main.cpp file. generated qmake project file (from current directory of main.cpp) , added header , cpp with:
headers += $$quote(/home/myusername/projects/src/myclass.h) sources += $$quote(/home/myusername/projects/src/myclass.cpp) sources += main.cpp
when run makefile, seems work until gets part of main.cpp include header file , says: fatal error, no such file or directory
i feel i'm making basic mistake, can't seem figure out.
first, using absolute paths in project file bad idea.
if class part of project, located in directory, use relative paths both in project file , in #include
directive, using #include "relative/path/myclass.h"
syntax.
if class not part of project, should compile library, use qmake following options:
qmake includepath+=/path/to/the/header libs+=-l/path/to/the/library
and add library name project file:
libs += -llibraryname
then may include class #include <myclass.h>
, note <>
syntax.
note workstation-specific things go command line, workstation-independent library name goes project file. if want provide sensible default location, use following trick:
unix { # default path unix systems isempty(mylib_path): mylib_path = /usr/local } includepath += $$mylib_path/include libs += -l$$mylib_path/lib
then, if want, can still override path command line:
qmake mylib_path=/home/myusername/mylib
Comments
Post a Comment