【问题标题】:CLion on mac: configure package pathmac上的CLion:配置包路径
【发布时间】:2018-01-15 18:32:39
【问题描述】:

我有一些 C++ 项目并导入到 CLion。现在在头文件中,如果我有这一行它不起作用:

#include "myproject/some_header_file.h"

如果我将其更改为以下内容,则可以:

#include "../some_header_file.h"

这对我来说真的很奇怪,有人知道如何配置 IDE 以使其使用第一行工作吗?否则我需要改变所有的地方让它工作......

谢谢!

【问题讨论】:

  • #include "..." form 接受相对于当前文件位置的路径,如果相对路径中的文件丢失,则回退到已知的包含目录。所以第二种形式是正确的。

标签: c++ ide clion


【解决方案1】:

您可以使用 CMakeLists.txt 文件在 CLion 上设置包含路径。

只需在您的CMakeLists.txt 中写入include_directories(.)

请注意,#include 到包含路径中的目录是使用 <> insted of "" 完成的。

像这样: #include <myproject/some_header_file.h>

【讨论】:

    猜你喜欢
    • 2011-06-22
    • 2015-02-07
    • 2019-04-21
    • 2018-11-22
    • 2020-02-12
    • 2014-05-19
    • 2016-02-06
    • 2018-10-08
    • 1970-01-01
    相关资源
    最近更新 更多