473,406 Members | 2,217 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,406 software developers and data experts.

C compilation error on RHEL3

Hi,

Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything else
that I should do in this case? BTW, this linux (Red Hat linux) Thanks.

Apr 19 '06 #1
21 1616
thua...@hotmail.com wrote:
Hi,

Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything else
that I should do in this case? BTW, this linux (Red Hat linux) Thanks.


The name of the include file is seached in an implementation defined
way, check your documentation for the details. Many implementations
allow you to specify the full pathname of the file or add directories
to be seached using a command-line option. For example, if you are
using gcc, check out the -I option.

Robert Gamble

Apr 19 '06 #2
th*****@hotmail.com wrote:

Myfile.c include a "Otherfile.h" and this file is under
different
directory. When I compile Myfile.c, the compiler says
"Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in
PATH
environment variable. It still does not compile. Is there
anything else
that I should do in this case?


Changing PATH will not do. Try:

#include "path/Otherfile.h"

Apr 19 '06 #3
th*****@hotmail.com wrote:
Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything else
that I should do in this case? BTW, this linux (Red Hat linux) Thanks.

1. This query is not specific to ANSI C, and this group is quite strict
about off-topic posts. Check your system documentation.

2. If you checked your documentation you will find references to
something called the "include path". This is the key to your problem.
Apr 19 '06 #4
Vladimir S. Oka said:
th*****@hotmail.com wrote:

Myfile.c include a "Otherfile.h" and this file is under
different
directory. When I compile Myfile.c, the compiler says
"Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in
PATH
environment variable. It still does not compile. Is there
anything else
that I should do in this case?


Changing PATH will not do. Try:

#include "path/Otherfile.h"


Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.

Better: use the compiler's include path switch (e.g. in gcc it's -I) to
specify where to look for headers.

Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 19 '06 #5
th*****@hotmail.com wrote:
Hi,

Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything
else that I should do in this case? BTW, this linux (Red Hat linux)

Most compilers have a method to set additional include paths. Check
your documentation, find a newsgroup or forum for your compiler, or
search the web for those words.

Brian
Apr 19 '06 #6
On 2006-04-19, Richard Heathfield <in*****@invalid.invalid> wrote:
Vladimir S. Oka said:
th*****@hotmail.com wrote:

Myfile.c include a "Otherfile.h" and this file is under
different
directory. When I compile Myfile.c, the compiler says
"Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in
PATH
environment variable. It still does not compile. Is there
anything else
that I should do in this case?
Changing PATH will not do. Try:

#include "path/Otherfile.h"


Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.


Why is it non-portable? The / will always work (even if the development
system uses a different directory separator), and so long as you stick
to relative paths (relative to the include directories for the build). I
always thought this should be all right.
[...]
Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).


<OT>

This might not be the best way to organize the headers in every case
though. It's a UNIX convention to put all the headers from all packages
in one place, all the executables from all packages in another place,
and all the libs in another. But on other systems things are organized
differently, for example the headers, executables and libs may all go
beneath different subdirectories for each package. On Windows for
example you see dirs called things like "C:\Program Files\My Favorite
Program\Include\" which is where the headers for "My Favorite Program"
go.

Also, thuang2 may not have write access to /usr/local/include.

</OT>
Apr 19 '06 #7
Ben C <sp******@spam.eggs> writes:
On 2006-04-19, Richard Heathfield <in*****@invalid.invalid> wrote:
Vladimir S. Oka said:
th*****@hotmail.com wrote:

Myfile.c include a "Otherfile.h" and this file is under
different
directory. When I compile Myfile.c, the compiler says
"Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in
PATH
environment variable. It still does not compile. Is there
anything else
that I should do in this case?

Changing PATH will not do. Try:

#include "path/Otherfile.h"


Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.


Why is it non-portable? The / will always work (even if the development
system uses a different directory separator), and so long as you stick
to relative paths (relative to the include directories for the build). I
always thought this should be all right.


What makes you think the / will always work? The standard makes no
such guarantee.

It happens to be interpreted as a directory delimiter on most modern
systems used for development (Unix-like systems, MS DOS and Windows),
and if you don't care about portability beyond such systems you can
use it. Things like "#include <sys/foobar.h>" are common on Unix-like
systems.

Otherwise, your best bet is to use just the name of the header file
and use some compiler-specific method to tell the compiler where to
look.
[...]
Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).


<OT>

This might not be the best way to organize the headers in every case
though. It's a UNIX convention to put all the headers from all packages
in one place, all the executables from all packages in another place,
and all the libs in another. But on other systems things are organized
differently, for example the headers, executables and libs may all go
beneath different subdirectories for each package. On Windows for
example you see dirs called things like "C:\Program Files\My Favorite
Program\Include\" which is where the headers for "My Favorite Program"
go.

Also, thuang2 may not have write access to /usr/local/include.

</OT>


Putting the headers for one particular project in a system-wide
directory is ok if and only if you want to make those headers
available system-wide. If they're local to one project, you probably
want to keep them in the directory (or directory tree) for that
project.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 20 '06 #8
Richard Heathfield opined:
Vladimir S. Oka said:
#include "path/Otherfile.h"


Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.


You are, of course, absolutely right.

<OT type="excuse">
I should have refrained from testing Usenet access from my PDA on c.l.c
(in the header of the offending post you'll find: "User-Agent:
Yanoff-/3.2 (Palm)"). I actually thought I cancelled the post, but pen
based input on a tiny screen got the better of me.
</OT>

Anyway, I won't do it again...

--
Peace was the way.
-- Kirk, "The City on the Edge of Forever", stardate unknown

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 20 '06 #9
On 2006-04-19, Keith Thompson <ks***@mib.org> wrote:
Ben C <sp******@spam.eggs> writes:
On 2006-04-19, Richard Heathfield <in*****@invalid.invalid> wrote:
Vladimir S. Oka said:
[snip]
#include "path/Otherfile.h" Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.
Why is it non-portable? The / will always work (even if the development
system uses a different directory separator), and so long as you stick
to relative paths (relative to the include directories for the build). I
always thought this should be all right.
What makes you think the / will always work? The standard makes no
such guarantee.
I drew the wrong conclusion from the fact that it usually does work.
It happens to be interpreted as a directory delimiter on most modern
systems used for development (Unix-like systems, MS DOS and Windows),


MS DOS (and some versions of Windows?) use \ in the shell, but you can
often use either \ or / in your #include directives.

As you say, though, this isn't standard, it's just the particular
preprocessor doing you a favour.

Thanks for putting me right on this one.
Apr 20 '06 #10

Ben C schrieb:

MS DOS (and some versions of Windows?) use \ in the shell, but you can
often use either \ or / in your #include directives.
Indeed, "/" should always be fine on DOS and successors, while "\\"
will never work on UN*X.
As you say, though, this isn't standard, it's just the particular
preprocessor doing you a favour.


Do you think the preprocessor interprets the character string between
".." or <...> in any way other than to pass it straight to fopen()?

Apr 20 '06 #11
On Wed, 19 Apr 2006 22:22:57 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalid> wrote:
Bad idea. Sorry, Vladimir, but that's a surefire way to make the code
non-portable.
to a small extent. The "path/to/there/.h" syntax works on pretty much
all Osen I've worked with, including, surprisingly, VMS.
Better: use the compiler's include path switch (e.g. in gcc it's -I) to
specify where to look for headers.
Absolutely. Thats what the switch is for. :-)
Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).


Absolutely NOT. Do not clutter your local include dir with app
headers. :-(
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Apr 20 '06 #12
Mark McIntyre said:
On Wed, 19 Apr 2006 22:22:57 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalid> wrote:
Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).


Absolutely NOT. Do not clutter your local include dir with app
headers. :-(


I use it for library headers. App headers are what the cwd is for.

You might deduce from this that I don't split app source up into separate
directories. If it makes sense to split off a bunch of code into a separate
directory, chances are good that it's a useful bunch of code that will be
happier in a library.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 20 '06 #13
On 2006-04-20, Ingo Menger <qu*********@consultant.com> wrote:

Ben C schrieb:

MS DOS (and some versions of Windows?) use \ in the shell, but you can
often use either \ or / in your #include directives.


Indeed, "/" should always be fine on DOS and successors, while "\\"
will never work on UN*X.


Yes, which is why it's usually better to use the '/', and also to
use the upper and lower case that the filenames actually have, because
this works on more platforms.
As you say, though, this isn't standard, it's just the particular
preprocessor doing you a favour.


Do you think the preprocessor interprets the character string between
".." or <...> in any way other than to pass it straight to fopen()?


I wondered about this, and then whether there's anything in any standard
about directory separators in paths passed into fopen, but couldn't find
anything.

Presumably then fopen with '/' as a directory separator works on MS DOS
etc.? The C standard doesn't of course require that #include be
implemented with fopen.
Apr 20 '06 #14
th*****@hotmail.com wrote:
Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile...


<off-topic>
The PATH environment variable sets the directory list that the shell
will search for executable files. It has no connection whatsoever with
the search list used by the C compiler/preprocessor for included
files.
For gcc you must specify it with a -Ipath_to_included_file in the
command line.
</off-topic>

This is a platform specific question, as opposed to a C language
question. Next time please use a RedHat, gcc or Linux forum.
Apr 20 '06 #15
Roberto Waltman wrote:

th*****@hotmail.com wrote:
Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile...
<off-topic>
The PATH environment variable sets the directory list that the shell
will search for executable files. It has no connection whatsoever with
the search list used by the C compiler/preprocessor for included
files.
For gcc you must specify it with a -Ipath_to_included_file in the
command line.


Some compilers use an environment variable similar to PATH, which is
used to list the #include directories, and is useful in that you don't
have to change scripts/makefiles/whatever you use to compile multiple
sets of files.

Again, however, this is dependent on your particular compiler.
</off-topic>


--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Apr 20 '06 #16
On Thu, 20 Apr 2006 14:21:49 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalid> wrote:
Mark McIntyre said:
On Wed, 19 Apr 2006 22:22:57 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalid> wrote:
Better still: shove the headers in a place the compiler always looks in
anyway (e.g. /usr/local/include is common on Linux systems).


Absolutely NOT. Do not clutter your local include dir with app
headers. :-(


I use it for library headers. App headers are what the cwd is for.

You might deduce from this that I don't split app source up into separate
directories. If it makes sense to split off a bunch of code into a separate
directory, chances are good that it's a useful bunch of code that will be
happier in a library.


I tend to distinguish quite carefully between a library thats private
to the current app, and a library thats shared amongst several apps.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Apr 20 '06 #17
Mark McIntyre said:
I tend to distinguish quite carefully between a library thats private
to the current app, and a library thats shared amongst several apps.


If it's only ever going to be used by the current app, I generally won't
bother librarising it at all. I just pile it all into the app directory. If
that results in an unmanageable amount of source in that directory, it
almost certainly means I've missed an opportunity to factor out some
functionality that could be useful in other programs too.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 20 '06 #18

Ben C schrieb:
On 2006-04-20, Ingo Menger <qu*********@consultant.com> wrote:
As you say, though, this isn't standard, it's just the particular
preprocessor doing you a favour.


Do you think the preprocessor interprets the character string between
".." or <...> in any way other than to pass it straight to fopen()?


I wondered about this, and then whether there's anything in any standard
about directory separators in paths passed into fopen, but couldn't find
anything.

Presumably then fopen with '/' as a directory separator works on MS DOS
etc.?


Yes it does. Some MS-DOS commands interpret the "/" in the commandline
as indicator for options, though. But this is a different story.
The C standard doesn't of course require that #include be
implemented with fopen.


Sure, but generally it does not make sense to parse a path name in an
application. It makes more sense to let the OS figure that out. The
reason why nothing is mentioned about directory separators (or, for
that matter, also drive letters) is most likely that the preprocessor
does not need to know anything about file systems, disk drives, mount
points, etc. It just needs a method to map a string (file name) to a
stream of bytes (file content).

Apr 20 '06 #19
Ben C <sp******@spam.eggs> writes:
On 2006-04-20, Ingo Menger <qu*********@consultant.com> wrote:

[...]
Do you think the preprocessor interprets the character string between
".." or <...> in any way other than to pass it straight to fopen()?


I wondered about this, and then whether there's anything in any standard
about directory separators in paths passed into fopen, but couldn't find
anything.


The standard says nothing about directories. As far as the C standard
is concerned, the file name passed to fopen() is just a string, to be
interpreted in some system-specific manner.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 20 '06 #20
cthua...@hotmail.com wrote:
Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything else
that I should do in this case? BTW, this linux (Red Hat linux) Thanks.
2. If you checked your documentation you will find references to
something called the "include path". This is the key to your problem.


How can I add more "include path" to gcc compiler on RHEL3. Thanks a
lot!

Apr 21 '06 #21
th*****@hotmail.com writes:
cthua...@hotmail.com wrote:
Myfile.c include a "Otherfile.h" and this file is under different
directory. When I compile Myfile.c, the compiler says "Otherfile.h: No
such file or directory" I include the path to "Otherfile.h" in PATH
environment variable. It still does not compile. Is there anything else
that I should do in this case? BTW, this linux (Red Hat linux) Thanks.

2. If you checked your documentation you will find references to
something called the "include path". This is the key to your problem.


How can I add more "include path" to gcc compiler on RHEL3. Thanks a
lot!


Asked and answered in another thread.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 21 '06 #22

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

Similar topics

2
by: zhengfish | last post by:
Hi,All, I try to install mysql-5.0.15 on RHEL3-U5. But It give me a error. MySQL-client-standard-5.0.15-0.rhel3.i386.rpm MySQL-devel-standard-5.0.15-0.rhel3.i386.rpm...
2
by: zeb nest | last post by:
Hello, I have some problem to launch db2setup (install procedure for db2v8fp3) under linux (redhat 9.0) : /home/root/db2v8/conpe/db2/linux/install/db2jinst: line 131: 4359 Erreur de...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
6
by: Plat | last post by:
I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology. Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax...
0
by: Devrim GUNDUZ | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I've built PostgreSQL 7.4.3 RPMS on RHEL3. Needed to change the spec file a bit for tcl and kerberos. They heve been tested and are working...
2
by: javier wilson | last post by:
i just build the rpm for rhel3 based on postgresql-7.4.3-3PGDG.src.rpm but i did not get the postgresql-tcl package. i looked for it in some mirrors like...
2
by: thuang2 | last post by:
Hi, How can I add more include path to gcc compiler on RHEL3? When re-compile C source code, do I have to do a "touch" command (by typing "touch myfile.c") before running "make" command? ...
1
JohanK
by: JohanK | last post by:
Hi there, I really need some help setting up mySQL. I'm running redhat enteprise linux 3.1 and the following rpm's are installed, mysql-3.23.58-16.RHEL3.1 libdbi-dbd-mysql-0.6.5-5...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.