How to include header files in GCC search path?

后端 未结 3 2141
深忆病人
深忆病人 2020-11-27 04:39

I have the following code in a sample file:

#include \"SkCanvas.h\"
#include \"SkDevice.h\"
#include \"SkGLCanvas.h\"
#include \"SkGraphics.h\"
#include \"Sk         


        
相关标签:
3条回答
  • 2020-11-27 04:59

    Using environment variable is sometimes more convenient when you do not control the build scripts / process.

    For C includes use C_INCLUDE_PATH.

    For C++ includes use CPLUS_INCLUDE_PATH.

    See this link for other gcc environment variables.

    Example usage in MacOS / Linux

    # `pip install` will automatically run `gcc` using parameters
    # specified in the `asyncpg` package (that I do not control)
    
    C_INCLUDE_PATH=/home/scott/.pyenv/versions/3.7.9/include/python3.7m pip install asyncpg
    

    Example usage in Windows

    set C_INCLUDE_PATH="C:\Users\Scott\.pyenv\versions\3.7.9\include\python3.7m"
    
    pip install asyncpg
    
    # clear the environment variable so it doesn't affect other builds
    set C_INCLUDE_PATH=
    
    0 讨论(0)
  • 2020-11-27 05:05

    The -I directive does the job:

    gcc -Icore -Ianimator -Iimages -Ianother_dir -Iyet_another_dir my_file.c 
    
    0 讨论(0)
  • 2020-11-27 05:08

    Try gcc -c -I/home/me/development/skia sample.c.

    0 讨论(0)
提交回复
热议问题