Makefile vpath not working for header files

前端 未结 1 1838
忘掉有多难
忘掉有多难 2021-01-15 02:55

I am trying to use vpath in my Makefile to avoid prefixing every source file with directory name. But I can\'t get it to work properly.

Here\'s the Makefile:

1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-15 03:23

    The vpath directive only controls how Make finds dependencies; it doesn't affect in any way how GCC works. If you have headers in some other directory, you explicitly need to tell GCC with -I:

    INCLUDE := include
    
    $(CC) -I$(INCLUDE) $c $< -o $@
    

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