【发布时间】:2021-02-19 02:36:47
【问题描述】:
我正在尝试调试此存储库:MP-SPDZ,其中许多.h、.hpp 和.cpp 文件放置在不同的文件夹中。此外,在每个.cpp 文件中,都包含几个头文件。
这里更清楚的是文件树的样子:
>ProjectTP
>Machines
-mascot-party.cpp
-SPDZ.cpp
-SPDZ.hpp
-Player-Online.cpp
-Player-Online.hpp
-more files ...
>Processor
-Machine.h
-Machine.hpp
-more files ...
>More folders ...
请注意,在某些情况下,.hpp 文件被视为.h 文件,而在其他一些情况下,它们被视为.cpp 文件。问题是当我尝试编译项目时,VS Code 找不到标头,而我将所有包含路径添加到 task.json。
这是我的主要.cpp 文件(mascot-party.cpp),它位于根目录中名为Machines 的文件夹中。
#include "Player-Online.hpp"
#include "Math/gfp.hpp"
#include "GC/TinierSecret.h"
int main(int argc, const char** argv)
{
ez::ezOptionParser opt;
return spdz_main<Share<gfp>, Share<gf2n>>(argc, argv, opt);
}
这是Player-Online.hpp 包含在(mascot-party.cpp) 中(只是为了显示存储库的嵌套程度)
#include "Processor/Machine.h"
#include "Processor/OnlineOptions.h"
#include "Math/Setup.h"
#include "Protocols/Share.h"
#include "Tools/ezOptionParser.h"
#include "Networking/Server.h"
#include <iostream>
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
template<class T, class U>
int spdz_main(int argc, const char** argv, ez::ezOptionParser& opt, bool live_prep_default = true)
...
return 0;
}
这是我的task.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/Machines/mascot-party.cpp",
//"${workspaceFolder}/Machines/SPDZ.cpp",
"${workspaceFolder}/Tools/*.cpp",
"${workspaceFolder}/Math/*.cpp",
"${workspaceFolder}/OT/*.cpp",
"${workspaceFolder}/Networking/*.cpp",
"${workspaceFolder}/Processor/*.cpp",
"${workspaceFolder}/Protocols/*.cpp",
"${workspaceFolder}/Machines/*.hpp",
"${workspaceFolder}/Tools/*.hpp",
"${workspaceFolder}/Math/*.hpp",
"${workspaceFolder}/OT/*.hpp",
"${workspaceFolder}/Processor/*.hpp",
"${workspaceFolder}/Protocols/*.hpp",
"-Idir",
"${workspaceFolder}/Processor",
"${workspaceFolder}/Tools",
"${workspaceFolder}/Math",
"${workspaceFolder}/OT",
"${workspaceFolder}/Networking",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/g++"
}
]
}
还有我的c_cpp_properties.json:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
重要提示:当我将绝对路径放入我的 .cpp 文件(例如,我放入 #include "/home/user/MP-SPDZ_VSCode/Processor/Machine.h" 而不是 #include "/home/user/MP-SPDZ_VSCode/Processor/Machine.h")时,它会找到标题。但是,存储库很大,无法通过这种方式修复它。
我尝试了很多不同的配置这么久,但没有结果。任何帮助表示赞赏。谢谢。
【问题讨论】:
标签: c++ ubuntu visual-studio-code