LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-20-2009, 12:14 PM   #1
kvm1983
Member
 
Registered: Jul 2009
Posts: 47

Rep: Reputation: 0
Recursively include headers in include option for gcc


Hello all,
Is there a way to recursively include all header files in the gcc command
"cc -I ..."

I have a directory with tens of subdirectories, each of which have header files in them. So while compiling a program test.c, I have a very long cc command like
"cc -I /home/dir/subdir1 -I /home/dir/subdir2 -I /home/dir/subdir3 ..... test.c"

If there could be a way to recursively include all header files in a directory, the compilation command would be pretty short in length.

Thanks,
Kshitij
 
Old 10-20-2009, 06:14 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Rep: Reputation: 167Reputation: 167
AFAIK you cannot do it with GCC alone
 
Old 10-21-2009, 04:07 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,522

Rep: Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503
"cc -I ..." is OK.
The alternative is a Makefile.

This example is a snippet from ns-2.33/Makefile.in
Code:
    63	
    64	INCLUDES = \
    65		-I. @V_INCLUDE_X11@ \
    66		-I. \
    67		@V_INCLUDES@ \
    68		-I./tcp -I./sctp -I./common -I./link -I./queue \
    69		-I./adc -I./apps -I./mac -I./mobile -I./trace \
    70		-I./routing -I./tools -I./classifier -I./mcast \
    71		-I./diffusion3/lib/main -I./diffusion3/lib \
    72		-I./diffusion3/lib/nr -I./diffusion3/ns \
    73		-I./diffusion3/filter_core -I./asim/ -I./qs \
    74		-I./diffserv -I./satellite \
    75		-I./wpan
    76
 
Old 09-04-2012, 02:56 PM   #4
mischasan
LQ Newbie
 
Registered: Sep 2012
Posts: 2

Rep: Reputation: Disabled
The shell is your friend; and your "-I" options are being used in a shell command invoking gcc.
So it is totally legit:
INCLUDE = ..... \
`find /home/dir/subdir[12345] -type d | sed s/^/-I/` # note the (`) backquotes
 
Old 09-04-2012, 02:58 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by mischasan View Post
The shell is your friend; and your "-I" options are being used in a shell command invoking gcc.
So it is totally legit:
INCLUDE = ..... \
`find /home/dir/subdir[12345] -type d | sed s/^/-I/` # note the (`) backquotes
This thread is three years old...
 
Old 09-04-2012, 03:21 PM   #6
mischasan
LQ Newbie
 
Registered: Sep 2012
Posts: 2

Rep: Reputation: Disabled
Yah, I guess I have too much time on my hands ... and the post showed up in google search, ABOVE one of my own blog posts on a related topic.
 
  


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
Differences between /usr/include/* and linux/include/* simopal6 Linux - General 2 08-26-2007 03:41 AM
changing include directories - /usr/local/include quep_fly Linux - Newbie 6 08-12-2007 04:36 PM
which headers usr/include/ or /usr/include/nptl/? Chris.Rector Linux - Enterprise 0 02-02-2007 01:40 PM
Updating kernel headers /usr/include/linux mhansen Slackware 4 11-30-2006 06:31 AM
Unable to include headers in Makefile Raphexion Programming 2 11-05-2005 08:00 AM


All times are GMT -5. The time now is 01:14 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration