Where is the implementation of included C++/C header files?

后端 未结 4 1670
我寻月下人不归
我寻月下人不归 2021-01-15 04:11

This may seem a little stupid:) But it\'s been bothering a while. When I include some header files which are written by others in my C++/C program, how does the compiler kno

4条回答
  •  忘掉有多难
    2021-01-15 04:51

    In general, the implementation is distributed as form of pre-compiled libraries. You need to tell the compiler where they are located.

    For example, for gcc, quoting the online manual

    -llibrary
    -l library
    

    Search the library named library when linking. [...]

    and,

    -Ldir
    

    Add directory dir to the list of directories to be searched for -l.


    Note: you don't need to explicitly specify the standard libraries, they are automatically linked. Rather, if you don't want them to be linked with you binary, you need to inform the compiler by passing the -nostdlib option.

提交回复
热议问题