I am working in ubuntu under c++ language.
I have a question: i use #include"header.h"
. Is this the same with /path/header.h
? I ask you this question because as I've seen is not the same thing. Need some explications.
I ask you this question because I've downloaded and install gsoap on my computer. I added all the necessary dependencies in a folder and I've tried to run the app without installing gsoap ...on a different computer. I had some errors..i forgot to add stdsoap2.h file...I will add it today..in my folder..
If header.h
is in the directory path/
, then #include "header.h"
will work for those header and source files (which #include
header.h which happen to be in the same directory as header.h
(path/
).
On the other hand, if you are #include
-ing header.h
in a file that is in a different directory than path/
, then the above way would not work. To make it work, you can try 2 different approaches:
#include
the complete path to header.h
. Your #include
will look something like:
#include "path/header.h"
path/
directory to the makefile
. This will get g++
to look for header.h
in those directories as well. This can be done like so (in the makefile):g++ <some parameters> -Ipath/ -c main.cpp -o main.o
(assuming header.h
is called from within main.cpp
). If you choose this way, then the #include
will also change, like so:#include <header.h>
. Note the use of the -I
flag as a parameter to g++. That flag tells g++ to look into additional directories as well.