What is the difference between -I and -L in makefile?

前端 未结 3 845
夕颜
夕颜 2020-12-07 11:32

What is the usage of the -I and -L flags in a makefile?

3条回答
  •  臣服心动
    2020-12-07 11:48

    To really grok a makefile, you need to also have a good understanding of the command lines for all of the components of your project's toolchain. Options like -I and -L are not understood by make itself. Rather, make is attempting to create a command line that will execute a tool to transform a prerequisite file into a target file.

    Often, that is a C or C++ source file being compiled to an object file, and eventually linked to get an executable file.

    In that case, you need to see the manual for your compiler, and especially the bits related to the command line options it understands.

    All that said in generic terms, those specific options are pretty standard among compilers and linkers. -I adds a directory to the list of places searched by the compiler for a file named on a #include line, and -L adds a directory to the list of places searched by the linker for a library named with the -l option.

    The bottom line is that the "language" of a makefile is a combination of the syntax of the makefile itself, your shell as known to make (usually /bin/sh or something similar), common shell commands (such as rm, cp, install, etc.), and the commands specific to your compiler and linker (e.g. typing gcc -v --help at your shell prompt will give you a nearly complete (and extremely long) list of the options understood by gcc as one starting point).

提交回复
热议问题