473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
Dec 13 '05 #1
3 2057
Peter Rothenbuecher wrote:
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

Dec 13 '05 #2
Peter Rothenbuecher wrote:
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
--
Stefan Naewe
naewe.s_AT_atlas_DOT_de
Dec 13 '05 #3

mlimber wrote in message
<11*********************@z14g2000cwz.googlegroups. com>...
Peter Rothenbuecher wrote:
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
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


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.

--
Bob R
POVrookie
Dec 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeff Wagner | last post by:
Is it possible to append a new Path to some file permanently? It seems like a sys.path.append('/my/new/path') statement is temporary. In other words, where and in what file on a Win32 box or...
1
by: Hafeez | last post by:
I am having real trouble compiling this code http://www.cs.wisc.edu/~vganti/birchcode/codeHier/AttrProj.tgz The attachment shows errors when compiled using the current version of g++ in a...
7
by: Ebay boy | last post by:
I have recently bought a compiler and I have this sample code that includes the following: #include <stdlib.h> #include <string.h> #include <time.h> Unfortunately, my compiler doesn't...
6
by: PengYu.UT | last post by:
The following code open the file "example.txt" in the current directory. int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close();...
11
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't...
10
by: wo_shi_big_stomach | last post by:
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. ...
1
by: Bigrabid | last post by:
Howdy, I have an access database that I use to keep track of projects that my group is working on. There are a number of files associated with any one project, so I have as a parent to , which...
2
by: dave6502 | last post by:
Struggling newbe here, some of my #includes work, some dont. Is it possible to list the include path ? (in BASH), I have looked at the environmental variables (loads of them) but cannot find a...
3
by: Ed | last post by:
Hi, dear all, Sometimes, when I debug my program, VS seems very smart to find the cpp file even if the file was not in the working directory. I am wondering how did VS try to find the cpp file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.