How can I set up the path where the compiler(g++) will search forthe header files

  • Thread starter Peter Rothenbuecher
  • Start date
P

Peter Rothenbuecher

Hello,
I have the following problem. I try to compile a .cpp file with an
include statement. But the included header file is in another dir. How
can I tell my compiler where to search for it.


This is the c++ compiler which I use:

g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)

thanks,
Peter
 
M

mlimber

Peter said:
Hello,
I have the following problem. I try to compile a .cpp file with an
include statement. But the included header file is in another dir. How
can I tell my compiler where to search for it.


This is the c++ compiler which I use:

g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)

thanks,
Peter

This question is off-topic here, since it is compiler-specific. You
should consult the compiler documentation (or just type "g++ --help").

Cheers! --M
 
?

=?ISO-8859-1?Q?Stefan_N=E4we?=

Peter said:
Hello,
I have the following problem. I try to compile a .cpp file with an
include statement. But the included header file is in another dir. How
can I tell my compiler where to search for it.


This is the c++ compiler which I use:

g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)

'man gcc' or 'man g++'

F'up to gnu.gcc.help
 
B

BobR

mlimber wrote in message
This question is off-topic here, since it is compiler-specific. You
should consult the compiler documentation (or just type "g++ --help").
Cheers! --M

An somewhat OnTopic answer could be:
In the #include, give the full path relative to the current directory.
#include "../../../myspecial/dingdong.h"
or, a full path.
#include "/home/me/mydev/myspecial/dingdong.h"

But, knowing the '-I'(upper-case i) and '-L' switches in GCC is a good thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top