【问题标题】:g++ compile included header: no such file or directoryg ++编译包含的头文件:没有这样的文件或目录
【发布时间】:2020-07-07 15:44:12
【问题描述】:

所以这个问题已经被问了很多次了,但我在 2 小时内都没有解决我的问题,希望有人能帮助我,可能只有 1 或 2 件小事...

我在我的文件中包含一个 .hpp,vscode 没有问题(配置了包含路径)但是当我尝试编译程序时出现错误:没有这样的文件。 Codesn-ps 如下。

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.18362.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe",
            "includePath": [
                "D:/foo/bar/boost_1_62_0/boost"
            ],
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

tests.cpp

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE HELLO
#include "test/unit_test.hpp"

int substract (int a, int b) {
    return a-b;
}

BOOST_AUTO_TEST_CASE(subtractTest) {
    BOOST_CHECK(substract(9,6) == 3);
}

cmd编译命令

g++ -o tests -l/D:/foo/bar/boost_1_62_0/boost/test/unit_test.hpp -I/D:/foo/bar/boost_1_62_0/boost/test tests.cpp

致命错误:boost/test/unit_test.hpp:没有这样的文件或目录

非常感谢任何帮助!

【问题讨论】:

    标签: c++ g++ boost-test


    【解决方案1】:

    如果您以 ".../boost" 结束包含路径,则 #include 指令不应以 boost 开头。你所做的解析为"D:/foo/bar/boost_1_62_0/boost/boost/test/unit_test.hpp"

    【讨论】:

    • 我编辑了我的代码,但不幸的是我的问题没有解决。
    猜你喜欢
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    • 2021-12-13
    • 2017-12-13
    • 1970-01-01
    相关资源
    最近更新 更多