在按照本教程安装了适用于c ++的MongoDB驱动程序之后,我编写了一些代码,设法使用以下命令进行编译和运行:
c++ --std=c++11 main.cpp -o app $(pkg-config --cflags --libs libmongocxx) && D_LIBRARY_PATH=/usr/local/lib ./app
现在,我尝试使用Visual代码调试并启动我的代码。我既不使用Visual Studio,也不使用Visual Studio,因为我没有使用Linux,也没有使用NetBeans,因为我没有合适的JDK或Code :: Blocks,因为它太复杂而无法设置合适的环境。
我的问题是Visual Code无法设法找到#include
我需要使用MongoDB和Bsoncxx的几个:
我尝试launch.json
使用参数设置文件
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "/usr/local/lib"
}
]
但是我敢肯定,我做错了,而且我无法在互联网上找到任何解决方案。我可以继续编写代码,然后通过批处理文件编译并运行它,但是使用IDE更为方便。
要开始Intellisense
工作,您需要告诉Vscode您的includes
位置。为此,请执行以下操作:
C/C++
VSCode扩展c_cpp_properties.json
这是c_cpp_properties.json
我在上的一个小项目中使用的文件的示例WSL
。
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/deps/fmt/include/",
"${workspaceFolder}/deps/spdlog/include/",
"${workspaceFolder}/deps/CLI11/include/",
"${workspaceFolder}/deps/pugixml/include/"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
单击此链接以获取有关如何进行设置的完整教程。如何设置VSCode
特别注意本Configure the compiler path
节和各Create a build task
节
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句