ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.