Home  >  Q&A  >  body text

linux下如何编译多个cpp文件,并且所包含的头文件在另一个文件包里

我尝试在linux下编译别人写好的c++文件包,它的目录结构是这样的。

其中c++文件全部放在src里面。hpp文件全部放在include里面

当我用下面的命令去编译它的时候,发现他报如下的错误
我应该执行怎样的命令才能使它两个文件的内容都编译到?

迷茫迷茫2743 days ago831

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 16:20:24

    -ISet the include path. -I设置include路径。

    例如src和include同级,你在src目录下编译,加-I "../include"

    For example, if src and include are at the same level, you compile in the src directory and add -I "../include". Then you find that there are more dependencies, so you keep adding them. 🎜

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 16:20:24

    Just add the relevant paths to cmake

    reply
    0
  • 黄舟

    黄舟2017-04-17 16:20:24

    Write a Makefile directly. Isn’t compilation much more convenient? ! !

    reply
    0
  • Cancelreply