LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 07-20-2009, 05:20 AM   #1
nocturna_gr
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 699
Thanked: 0
about LD_INCLUDE_PATH


[Log in to get rid of this advertisement]
Hi,
a couple of questions about LD_INCLUDE_PATH. I export it from my "/root/.bashrc"
1/When gcc is executed, is LD_INCLUDE_PATH automagically included in the compilation process or must i do "-I${LD_INCLUDE_PATH}"?

2/I have tried the "-I${LD_INCLUDE_PATH}" solution, but although i DO include ALL corresponding paths, compiler still complains about "a couple" of missing header files. The problem is solved if i separately do "-Ipath" for the corresponding directories. Possible causes?

Thank you
nocturna_gr is offline  
Tag This Post , ,
Reply With Quote
Old 07-20-2009, 09:06 AM   #2
ntubski
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 698
Thanked: 50
LD usually refers to the linker, so it seems odd to call the place where you put your includes as the LD_INCLUDE_PATH.

Quote:
1/When gcc is executed, is LD_INCLUDE_PATH automagically included in the compilation process or must i do "-I${LD_INCLUDE_PATH}"?
According to the Environment Variables section of the gcc manual, gcc uses CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, and OBJC_INCLUDE_PATH for finding includes.

Quote:
2/I have tried the "-I${LD_INCLUDE_PATH}" solution, but although i DO include ALL corresponding paths, compiler still complains about "a couple" of missing header files. The problem is solved if i separately do "-Ipath" for the corresponding directories. Possible causes?
I don't think the -I option handles multiple directories.
ntubski is offline     Reply With Quote
Old 07-20-2009, 10:49 AM   #3
paulsm4
Senior Member
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 3,318
Thanked: 144
1. The "-L" switches you specify (at link time) can be overridden by the $LD_LIBRARY_PATH you specify (at runtime).

2. The converse isn't true: $LD_LIBRARY_PATH is *not* used during linking.

3. Compile-time includes ("-I") have nothing to do with linking.
"-I" is completely unrelated to either "-L" or "$LD_LIBRARY_PATH".
paulsm4 is offline     Reply With Quote
Old 07-20-2009, 12:03 PM   #4
nocturna_gr
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 699
Thanked: 0

Original Poster
First thnx everybody. Sorry paulsm, but my small experience makes it difficult to understand

Quote:
Originally Posted by paulsm4 View Post
1. The "-L" switches you specify (at link time) can be overridden by the $LD_LIBRARY_PATH you specify (at runtime).
By "overriden" you mean automatically, or by doing "-L${LD_LIBRARY_PATH}"? If yes isn't there a problem with multiple directories, as ntubski said?
Quote:
2. The converse isn't true: $LD_LIBRARY_PATH is *not* used during linking.
If it points to libraries and bin code, what is the meaning during compile time?

Quote:
3. Compile-time includes ("-I") have nothing to do with linking.
"-I" is completely unrelated to either "-L" or "$LD_LIBRARY_PATH".
nocturna_gr is offline     Reply With Quote
Old 07-20-2009, 02:42 PM   #5
ntubski
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 698
Thanked: 50
Quote:
By "overriden" you mean automatically, or by doing "-L${LD_LIBRARY_PATH}"? If yes isn't there a problem with multiple directories, as ntubski said?
Thus 'The "-L" switches', not '"-L" switch'.

Quote:
If it points to libraries and bin code, what is the meaning during compile time?
-L tells gcc where to find libraries, so the linker can see what symbols the library defines. For shared libraries (.so, similar to .dll on Windows), the library has to be found at runtime as well. That's where LD_LIBRARY_PATH is used (more info at 3.3.1. LD_LIBRARY_PATH).

So to sum up:
  • use -I, CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, or OBJC_INCLUDE_PATH for finding .h include files at compile time.
  • use -L or LIBRARY_PATH to find .a or .so library files at compile (more accurately link) time.
  • use LD_LIBRARY_PATH to find .so library files at runtime. I seem to remember there is a -R option that does something like this, but I can't seem to find it in the manual now.
  • LD_INCLUDE_PATH doesn't do anything.
  • multiple paths in variables are separated by ":".
  • -I and -L take one path at a time.
ntubski is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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



All times are GMT -5. The time now is 03:13 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration