[英]g++ compile included header: no such file or directory
So this has been asked alot of times but I havent been able to solve my problem within 2 hours, I hope someone can help me, probably there are only 1 or 2 minor things off...所以这个问题被问了很多次,但我无法在 2 小时内解决我的问题,我希望有人能帮助我,可能只有 1 或 2 个小问题...
Im including a.hpp in my file, vscode has no problems (includepath configured) but when I try to compile the program there is an error: no such file.我在我的文件中包含 a.hpp,vscode 没有问题(配置了包含路径)但是当我尝试编译程序时出现错误:没有这样的文件。 Codesnippets below.
下面的代码片段。
c_cpp_properties.json 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测试.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 compile command 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
fatal error: boost/test/unit_test.hpp: No such file or directory致命错误:boost/test/unit_test.hpp:没有这样的文件或目录
any help is greatly appreciated!任何帮助是极大的赞赏!
If you ended the include path with ".../boost"
, the #include
directive shouldn't start with boost.如果您以
".../boost"
结束包含路径,则#include
指令不应以 boost 开头。 What you did resolves to "D:/foo/bar/boost_1_62_0/boost/boost/test/unit_test.hpp"
你所做的解析为
"D:/foo/bar/boost_1_62_0/boost/boost/test/unit_test.hpp"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.