LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2003, 11:27 PM   #1
centr0
Member
 
Registered: Feb 2003
Location: Earth
Distribution: Slackware 9.1
Posts: 134

Rep: Reputation: 15
*.h files....where to put them for #include


i have *.h files that i want to access when writing in c. i run redhat 8 and was wondering where should i put the files?

thanks for your help
=]
 
Old 03-12-2003, 04:39 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
these are header files you have just created yourself? you can specify code to use a local relative path by using #include "header.h" rather than #include <header> this will then look for the h file in your current directory.
 
Old 03-12-2003, 09:57 AM   #3
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
If you want to have the header files in a different directory, you might find it easier to use the -I[include dir] option of gcc and <> brackets in the #include. This way, you don't have to keep typing the full path of the header in your source files.

Alex
 
Old 03-12-2003, 11:51 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
I would suggest using acid_kewpie's route. When you start writing for a new project, create a directory for it, then an "include" subdirectory. Any header files you create can be referenced like:

#include "include/header.h"

llama_meme's suggestion will work too. If you revisit the code later though, you may not remember header files were included on the command line. It's not intuitive (for me at least) to look there for it.

Last edited by Dark_Helmet; 03-12-2003 at 06:36 PM.
 
Old 03-12-2003, 06:24 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
quoting Dark_Helmet
It's not intuitive (for me at least) to look there for it.
Of course one could use Makefiles and look at them
when trying to re-use code ;)

Cheers,
Tink
 
Old 03-12-2003, 06:45 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Yep, Makefiles are great.

I'm quite <ahem> retentive though when it comes to programming style. Something about a computer science instructor, a LARGE crowbar, and lots of bruises... it's all kind of blurry... can't imagine why... but I digress...

I just can't convince myself to remove the paths from include statements. When I look at source code and come across something (like a typedef, #ifdef statements, and the like), then I like to jump to the top of the file and know exactly where to look for where all that stuff is defined. Ease of access to information... it's all about fewer files to look in...
 
Old 03-13-2003, 06:45 AM   #7
centr0
Member
 
Registered: Feb 2003
Location: Earth
Distribution: Slackware 9.1
Posts: 134

Original Poster
Rep: Reputation: 15
whats the default directory the compiler looks in for '#include <blah.h>'

im just learning C going very slowly. bare with me. =)
 
Old 03-13-2003, 07:26 AM   #8
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
Depends on how your system is set up. The only one you can be sure of is /usr/include.

Alex
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
X include files Gonto Linux - Software 8 01-22-2006 04:42 AM
where to put path to include file bonosa Linux - Newbie 1 05-25-2004 09:27 AM
g++ does not find include files StressedLemming Linux - Newbie 2 11-30-2003 07:12 AM
X include files evian Linux - General 6 03-25-2003 04:53 PM
GTK-2.0 and include files Hubas Programming 2 03-15-2002 08:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration