At this time, you should use the -I parameter in gcc. For example, your head/xxx.h position is in /path/to/libs/head/xxx.h, and when drinking, use #include "head/xxx.h". Just compile with the following parameters:
gcc lib/xxx.c -I/path/to/libs
man gcc is as follows:
-I dir
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I are searched before the
standard system include directories. If the directory dir is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the
special treatment of system headers are not defeated . If dir
begins with "=", then the "=" will be replaced by the sysroot
prefix; see --sysroot and -isysroot.
There should be a configuration option that sets the previously omitted path prefix. Clone the project, use sublime or something to globally search for the missing path characters, and you will know where it is configured. Normally when you write a program, the previous #include<stdio.h> is not placed in the currently visible directory. The Linux system has some default environment variables like C_INCLUDE_PATH, which store some system paths. These paths are the header file paths that will be searched by default when you include. You can continue to add your own path later. I don’t know what platform your project is on. Like Android, when compiling jni, just use LOCAL_C_INCLUDES to specify the header file path, and the long header file path can be omitted from the code. . You can also search for keywords linux system header file search path and so on to learn relevant knowledge.
At this time, you should use the
-I
parameter in gcc. For example, yourhead/xxx.h
position is in/path/to/libs/head/xxx.h
, and when drinking, use#include "head/xxx.h"
. Just compile with the following parameters:man gcc
is as follows:There should be a configuration option that sets the previously omitted path prefix. Clone the project, use sublime or something to globally search for the missing path characters, and you will know where it is configured.
Normally when you write a program, the previous
#include<stdio.h>
is not placed in the currently visible directory. The Linux system has some default environment variables likeC_INCLUDE_PATH
, which store some system paths. These paths are the header file paths that will be searched by default when you include. You can continue to add your own path later.I don’t know what platform your project is on. Like Android, when compiling jni, just use LOCAL_C_INCLUDES to specify the header file path, and the long header file path can be omitted from the code. .
You can also search for keywords linux system header file search path and so on to learn relevant knowledge.