How to include header file through makefile

2020-02-12 08:04发布

I know that there is a flag that can be used in makefile to include a header file in all the files which are being compiled, just like there is a -D flag to include a define. What flag is exactly for including header files. I don't remember know.

2条回答
够拽才男人
2楼-- · 2020-02-12 08:47

In your compile command, you can use the -include option:

gcc -o main -include hello.h main.cpp 
查看更多
做自己的国王
3楼-- · 2020-02-12 08:48

something like this maybe? include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

查看更多
登录 后发表回答