LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   object files, compiling, location (https://www.linuxquestions.org/questions/linux-newbie-8/object-files-compiling-location-716297/)

icecubeflower 04-02-2009 06:07 AM

object files, compiling, location
 
When you compile a program with standard header files like <iostream> it looks to me like the compiler never compiles any .cpp files for them so I assume the .o files are all stored somewhere so all the compiler does is link them. Is that right?

I did this:
Code:

root@inferno:/home/icecube# find / -name iostream
/usr/include/boost/tr1/tr1/iostream
/usr/include/c++/4.2.4/iostream
/usr/local/boost_1_38_0/boost/tr1/tr1/iostream
/usr/local/include/boost-1_38/boost/tr1/tr1/iostream
root@inferno:/home/icecube#

And I installed boost myself so I guess /usr/include/c++/4.2.4 is where the isostream header file is at.

How does g++ know where to look for standard header files? Does it use the same PATH ($PATH?) variable (I can't remember what it's called) that the shell uses when tries to find executable files like ls?

knudfl 04-02-2009 07:42 AM

1) $PATH is for executable's :/bin:/usr/bin:/usr/local/bin etc.

2) LD_LIBRARY_PATH is for libraries (:/lib:/usr/lib: .. etc.)

3) c++ (g++), gcc has a 'build in' path, knowing where to look :

when gcc, g++ is compiled with '--prefix=/usr', the path for the
includes is ( for g++) /usr/include/c++/4.x.x/ ....
for the '4.x.x' versions.
.....


All times are GMT -5. The time now is 01:48 AM.