In Linux, these headers are usually in /usr/include, which belongs to search path. However, these are just header files. Where are the source codes or library of these header files?
They are defined in system libraries, such as libc or libstdc++. They are linked in by the linker after your sources are compiled. I would expect them to be found in the /usr/lib directory.
Thank you. I can see a lot of .so and .a files are in /usr/lib
So when g++ or gcc link them, they will automatically search these paths to find the library files ?
Any idea how to check what paths g++ or gcc will go thru to search the library files?
When I write the makefile to compile the codes, if in my codes I have used the library in /usr/lib, for example : libpcap.a or libpcap.so. Do I have to add flag : -lpcap in my makefile ?
Generally speaking is, if I use a library file (either .a or .so), I need add the corresponding flags to makefile as gcc or g++ option, correct?
> if in my codes I have used the library in /usr/lib, for example : libpcap.a or libpcap.so.
> Do I have to add flag : -lpcap in my makefile ?
> if I use a library file (either .a or .so), I need add the corresponding flags to makefile as gcc or g++ option, correct?