The default header file path when compiling code under linux

1 Application programming, header files in driver source code

1.1   The header file included in application programming is the header file of the application layer, which is brought by the compiler of the application 

1.1.1 When compiling applications under Windows

        1) The header files included with <> generally search the path after the -I option (that is, the -I option when compiling with gcc), and then the standard system header file path.
        2) The header files included with the "" sign will first search the current working directory, and the search path after that is the same path as the header file included with the <> sign. 3) When compiling programs of X86 architecture
        in linux system, the default standard header file path is:

             The following is the default header file path I got using cpp -v in linux under ubuntu

             /usr/lib/gcc/x86_64-linux-gnu/5/include
             /usr/local/include
             /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
             /usr/include/x86_64-linux-gnu

             /usr/include

1.1.2 When compiling applications for ARM architecture

        1)  When compiling programs of ARM architecture in linux system , the general default standard header file path is:

            The following is my linux under ubuntu, using arm-hisiv300-linux-cpp -v to get the path

              /opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/../lib/gcc/arm-hisiv300-linux-uclibcgnueabi/4.8.3/include

              /opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/../target/usr/include

      

        2) Specify by using -I etc. in the makefile    

                See porting of libjpeg library

        3) For example, on the HiSilicon platform, you need to use a cross-compilation tool to compile applications that can be used on the HiSilicon development board, as follows:

                #include <sys/stat.h>
                #include <sys/time.h>
                #include <fcntl.h>

                #include <errno.h>

               Use find -name "stat.h" on the Linux command line (note: use root user permissions to search in the topmost directory)

               ./opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/usr/include/sys/stat.h

        Summary: Compilation toolchains of different versions are written for their own platforms, such as an executable program gcc, arm-hisiv300-linux , arm-x210-linux-gcc in the toolchain. When the toolchain is installed, it contains There are all the header files required for compilation. The path to find the header files by default is where you installed them. As mentioned above, all we need to modify CC = arm-xxx-xxx in the makefile, etc., only when making Will use our specified cross-compilation toolchain.        

1.2 Header files when writing driver code

        (1) The driver source code is part of the kernel source code. The header file in the driver source code is actually the header file in the include directory in the kernel source code directory. When we #include, it will automatically search for the include
        (2) For example, for drivers, the included header files are in the installation directory of the kernel source code, namely /usr/src/kernel/include. At this time, the kernel source code directory is generally specified in the Makefile file, and INCLUDE is specified at compile time. directory, look at the directory you installed after unzipping

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325775864&siteId=291194637