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

后端 未结 4 1620
我寻月下人不归
我寻月下人不归 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:54

    As the others already explained, you need to tell your compiler where to look for the files. This implies that you should know which path to specify for your compiler.

    Some components provide a mechanism where you don't need to know the exact path but can automatically retrieve it from your system.

    For example if you want to compile using GTK+3 you need to specify these flags for your compiler:

    CFLAGS:= -I./ `pkg-config --cflags gtk+-3.0`

    LIBS:= -lm `pkg-config --libs gtk+-3.0`

    This will automatically result in the required include and library path flags for GCC.

提交回复
热议问题